python – Zsh: Conda/Pip installs command not found

python – Zsh: Conda/Pip installs command not found

I found an easy way. Just follow below steps:

  1. in terminal, enter vim ~/.zshrc
    enter
  2. add source ~/.bash_profile into .zshrc file
    enter
  3. and then in terminal, enter source ~/.zshrc
    enter

Congratulation for you!!! ㊗️

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.

python – Zsh: Conda/Pip installs command not found

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/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 ~/.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 dont forget to source ~/.zshrc

Leave a Reply

Your email address will not be published.