Zsh: Conda/Pip installs command not found

混江龙づ霸主 提交于 2019-11-30 06:20:47

问题


So I installed Anaconda and everything is working. After I installed it I decided to switch to oh-my-zsh. I am now getting:

zsh: command not found: conda

when trying to use pip or conda installs

echo $ZSH_VERSION

5.0.5

I have added to my zshenv.sh

export PATH ="/Users/Dz/anaconda/bin:$PATH"

What is it that I'm missing?


回答1:


As of today Nov 4, 2018 all the following methods works, install the zsh with:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Not recommending brew installation for zsh:

brew install zsh zsh-completions 

P.S: Tried with with brew and brew install under the root and is not an wise idea to do so due the security and all time anything related will need to be started under sudo so better is to stick with curl or wget.

to make work conda in OS X with oh-my-zsh installed is to add path as following and will work.

Find the python paths so can see if you installed Anaconda2 or Anaconda3: where python or which python will result in similar output:

/usr/bin/python
/Users/"username"/anaconda3/bin/python
/usr/bin/python

Finding your Anaconda Python interpreter path

vi ~/.zshrc or gedit ~/.zshrc

For Anaconda: at field # User configuration add:

PATH="$HOME/anaconda/bin:$PATH"

For Anaconda2 at field # User configuration add:

PATH="$HOME/anaconda/bin:$PATH"

For Anaconda3 at field # User configuration add:

PATH="$HOME/anaconda3/bin:$PATH"

or replace "username" with your username:

PATH="/Users/"username"/anaconda3/bin:$PATH


According to documentation Installing on macOS we add add in ~/.zshrc instead of .bashrc or .bash_profile

  • Add export PATH="/<path to anaconda>/bin:$PATH" in ~/.zshrc

  • Or set the PATH variable: export PATH="/<path to anaconda>/bin:$PATH"

Replace “<path to anaconda>” with the actual path to your Anaconda installation.

This methods are working on ubuntu/Centos7/MacOS as well (just close/reset the terminal once you are completing the changes) than just type conda to test.


Per @truongnm comment just source after adding the path: "I pasted the path from my bash_profile, and don't forget to source ~/.zshrc"




回答2:


I found an easy way. you can try to test it.

Just follow below steps as I show:

First, in terminal, enter

vim ~/.zshrc

add

source ~/.bash_profile

into .zshrc file

and then in terminal, enter

source ~/.zshrc

Congratulation for you.




回答3:


The anaconda installer automatically writes the correct PATH into the ~/.bash_profile file. Copy the line to your ~/.zshrc file, source it with source ~/.zshrc and you're good to go.




回答4:


It appears that my PATH is broken in my .zshrc file.

export PATH="$PATH;/Users/Dz/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/Dz/.rvm/bin"

Doh! Well that would explain everything. How did I miss that little semicolon? Changed:

export PATH="$PATH:/Users/Dz/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/Dz/.rvm/bin"

source ~/.zshrc
echo $HOME
echo $PATH

We're good now.




回答5:


This is all I had to add to add get anaconda working for zsh.

echo ". /anaconda3/etc/profile.d/conda.sh" >> ~/.zshrc
source ~/.zshrc



回答6:


I had this problem on my Catalina OSX after I installed my Anaconda distribution as well.

This solution worked for me on macOS Catalina as of October 19, 2019

Step 1. Check if .bash_profile is available on your home folder, if not:

  • Go to Terminal
  • Type cd ~/ to go to your home folder (if you are not on your home folder)
  • Type touch .bash_profile to create your new file under the your home folder

Step 2. Check if file .zshrc is available on your home folder, if not:

  • Go to terminal and type nano ~/.zshrc

  • Type in the following line into the newly created .zshrc file: source ~/.bash_profile

  • Now to save the file in nano just hit ctrl+X.

  • It will prompt "Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES)?". Just type in Y

Step 3. Check if .bash_profile and .zshrc files are created on your home folder. If yes, in terminal type in source ~/.zshrc




回答7:


I just ran into the same problem. As implicitly stated inside the .zshrc-file (in your user-root-folder), you need to migrate the pathes you've already inserted in your .bash_profile, bashrc or so to resolve this.

Copying all additional pathes from .bash_profile to .zshrc fixed it for me, cause zsh now knows where to look.

#add path to Anaconda-bin
export PATH="/Users/YOURUSERNAME!!/anaconda3/bin:$PATH"

 #N.B. for miniconda use
export PATH="/Users/YOURUSERNAME!!!/miniconda3/bin:$PATH"

Depending on where you installed anaconda this path might be different.




回答8:


You need to fix the spacing and quotes:

export PATH ="/Users/Dz/anaconda/bin:$PATH"

Instead use

export PATH="/Users/Dz/anaconda/bin":$PATH



回答9:


  1. Find the right version of your anaconda

  2. Put it to ~/.zshrc via command vim ~/.zshrc

    • Anaconda 2 export PATH="/User/<your-username>/anaconda2/bin:$PATH"
    • Anaconda 3 export PATH="/User/<your-username>/anaconda3/bin:$PATH"
    • Or if you install Anaconda in root directory:
    • Anaconda 2 export PATH="/anaconda2/bin:$PATH"
    • Anaconda 3 export PATH="/anaconda3/bin:$PATH"
  3. Restart the zsh source ~/.zshrc




回答10:


FYI for anyone having this same issue keep in mind that you need to make sure that you have the right version of anaconda in that export path:

anaconda2 or anaconda3 

Spent way too long on that minor issue.



来源:https://stackoverflow.com/questions/31615322/zsh-conda-pip-installs-command-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!