Zsh: Conda/Pip installs command not found
Solution 1
It appears that my PATH is broken in my .zshrc
file.
Open it and add :
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.
Solution 2
I found an easy way. Just follow below steps:
- in terminal, enter
vim ~/.zshrc
- add
source ~/.bash_profile
into .zshrc file - and then in terminal, enter
source ~/.zshrc
Congratulation for you!!! γοΈ πππ
Solution 3
If you are on macOS Catalina, the new default shell is zsh. You will need to run source /bin/activate followed by conda init zsh.
For example: I installed anaconda python 3.7 Version, type echo $USER
to find username
source /Users/my_username/opt/anaconda3/bin/activate
Follow by
conda init zsh
or (for bash shell)
conda init
Check working:
conda list
The error will be fixed.
Solution 4
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
orwhich python
will result in similar output:
/usr/bin/python
/Users/"username"/anaconda/bin/python # # previous path for anaconda
/Users/"username"/anaconda3/bin/python # # previous path for anaconda3
/Users/"username"/opt/anaconda/bin/python # # for current path anaconda
/Users/"username"/opt/anaconda3/bin/python # # for current path for anaconda3
one line config command:
echo -e '# >>> anaconda conda config >>> \nPATH="$HOME/opt/anaconda3/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc && conda init
Note: Anaconda do not recommend to add manually paths per following: Should I add Anaconda to the macOS or Linux PATH?
We do not recommend adding Anaconda to the PATH manually. During installation, you will be asked βDo you wish the installer to initialize Anaconda3 by running conda init?β We recommend βyesβ. If you enter βnoβ, then conda will not modify your shell scripts at all. In order to initialize after the installation process is done, first run source /bin/activate and then run conda init.
Note:
Replace <path-to-anaconda> with the actual path of your installed Anaconda file.
What is the default path for installing Anaconda?
If you accept the default option to install Anaconda on the βdefault pathβ Anaconda is installed in your user home directory:
-
Windows 10: C:\Users<your-username>\Anaconda3\
-
macOS: /Users//anaconda3 for the shell install, ~/opt for the graphical install. See installing on macOS.
-
Linux: /home//anaconda3
If your username includes spaces, as is common on Windows systems, you should not accept the default path. See In what folder should I install Anaconda on Windows?
I already have Python installed. Can I install Anaconda?
You do not need to uninstall other Python installations or packages before installing Anaconda. Even if you already have a system Python, another Python installation from a source such as the macOS Homebrew
package manager and globally installed packages from pip
such as pandas
and NumPy
, you do not need to uninstall, remove, or change any of them.
Install Anaconda or Miniconda normally. There is no need to set the PYTHONPATH
environment variable.
To see if the conda installation of Python is in your PATH variable:
-
On macOS and Linux, open the terminal and run echo
$PATH
. -
On Windows, open an Anaconda Prompt and run echo
%PATH%
.
To see which Python installation is currently set as the default:
- On macOS and Linux, open the terminal and run
which python
. - On Windows, open an Anaconda Prompt and run
where python
.
To see which packages are installed in your current conda environment and their version numbers, in your terminal window or an Anaconda Prompt, run conda list
.
For detailed info on adding manually see below info:
Finding your Anaconda Python interpreter path
vi ~/.zshrc or gedit ~/.zshrc
Anaconda updated to use similar to Anaconda Enterprise edition paths:
/opt/...
@update Dec 2021: For Anaconda3 at field# User configuration
add:
PATH="$HOME/opt/anaconda3/bin:$PATH"
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 ~/.zshrcOr 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
"
Solution 5
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.
Related videos on Youtube
Architek1
Learning...Processing and JavaScirpt with with Node.js throw in just to make it a little more difficult.
Updated on December 17, 2021Comments
-
Architek1 over 2 years
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
orconda
installsecho $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?
-
truongnm over 6 yearsI pasted the path from my bash_profile, and don't forget to source ~/.zshrc
-
wi3o over 6 years> source ~/.zshrc definitely helps!
-
AZhao over 6 yearsdocs.anaconda.com/anaconda/faq#id9 could it be the docs themselves are wrong? I spent an hour until i stumbled upon this.
-
Joel Colucci about 6 yearsThanks copying the PATH in ~/.bash_profile to ~/.zshrc worked for me.
-
Piotr Jankiewicz almost 6 yearsThe root direcotory! Thank you.
-
Aus_10 over 4 yearsThis worked for me. Thanks. Just for clarity: I copied there are several lines in .bash_profile installed by anaconda that I copied and put into .zshrc. Everything worked as expected afterwards.
-
Kyle Frye over 4 yearsIf anyone is here dealing with reinstalling after the Catalina OS update this is probably what you're looking for.
-
hzitoun over 4 years
source ~/.zshrc
is not enough, needed indeed to addsource ~/.bash_profile
so thanks! -
James N over 4 yearsthis worked for me on Macbook pro-2019 with macOS Catalina, thank you
-
redHair about 4 yearsThanks for the saving my time;)
-
nkirit about 4 yearsThis is no longer working in 2020 - add this to first line of ~/.zshrc
export PATH="/usr/local/anaconda3/bin:$PATH"
-
Pieter almost 4 yearsmacbook air 2019 model, catalina: works perfectly, many thanks
-
matthewpliddy over 3 yearsIf you install anaconda for all users (like me) use
source /opt/anaconda3/bin/activate
-
goe over 3 yearsPerfect solution with OSX 11
-
Ben2209 over 3 yearsthis is not the cleanest solution. There are better solutions like the one of @edwardyaho or mine below.
-
Bright Chang about 3 yearsGreat explanation! Thank you!
-
Adrian Aley almost 3 yearsThis is for MacOS but may work for others as well.
-
Ribena almost 3 yearsWARNING. This is not without risk. Doing this completely messed up my prompt. But my faulty for following steps devoid of an explanation.
-
Kearney over 2 yearson my basrc, it is
[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh
-
Tack_Tau over 2 yearsThis works perfectly on M1 Mac with BigSur 11.6, thanks!
-
user1207289 over 2 yearsAfter running above commands you'll start to get
(base)
in front of your zsh when a fresh zsh window is opened. To remove that runconda config --set auto_activate_base false
. Open new zsh and tryconda list
-
Hugo Lemieux-Fournier about 2 yearsThe default .bash_profile is now called .profile which can be seen in the HOME directory.
-
seeker_after_truth about 2 yearsHow is this actually working? And @Ben2209, how is this not the cleanest solution/what is wrong with it?
-
Ben2209 about 2 years@seeker_after_truth Sourcing .bash_profile when you actually are not using bash but zsh is some kind of workaround. Conda offers a command that inserts the right code in the .zshrc directly. See my answer below.
-
Nurseyit Tursunkulov about 2 yearsperfect solution
-
Sukanya Pai almost 2 yearsThis messed up my terminal and the bash was not getting exited after "Process completed" because apparently adding this line results in infinite loop and the terminal hangs.
-
Charlie Parker almost 2 yearsweird, why do we need to run bash_profile?
-
Charlie Parker almost 2 yearswhy aren't you running
.bach_profile
? -
Charlie Parker almost 2 yearswhy aren't you running
.bach_profile
? -
Charlie Parker almost 2 yearswhy aren't you running
.bach_profile
? -
Charlie Parker almost 2 yearshow do I find the path to
source /Users/my_username/opt/anaconda3/bin/activate
not sure where conda installed it's stuff... -
n1tk almost 2 yearsBecause question is tagged as zsh β¦