How To Install Anaconda On Linux, Windows, MacOS Correctly

Anaconda is a scientific Python distribution that contains a lot of not often used scientific python libraries. If you want to do data analysis, scientific computing, you can install the anaconda and use it to implement what you want.

But after I install anaconda on Linux, I found that I can not use it correctly. When I input command such as jupyter notebook, it shows error message like Error executing Jupyter command ‘notebook’: [Errno 2] No such file or directory. But you can follow this article to fix the errors.

1. Install Anaconda On Linux, Windows, MacOS.

  1. The anaconda installation is very simple and straightforward. The installation process on all three platforms ( Linux, Windows, macOS ) is very similar.
  2. But before that, you should download anaconda for your OS platform first. After that follow the below steps to install it on the different OS platforms.

1.1 Linux.

  1. Anaconda Linux install file is just a .sh file, it is executable.
  2. Open a terminal and run the file to install.
  3. The installation process is very straightforward. It will download and install a lot of dependency libraries.
  4. After installation, the anaconda bin directory path is also added in the system PATH env variable by changing your .bashrc ( /home/zhaosong/.bashrc ) file automatically as below.
    # added by Anaconda3 2018.12 installer
    # >>> conda init >>>
    # !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$(CONDA_REPORT_ERRORS=false '/home/zhaosong/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
    if [ $? -eq 0 ]; then
        \eval "$__conda_setup"
        if [ -f "/home/zhaosong/anaconda3/etc/profile.d/" ]; then
            . "/home/zhaosong/anaconda3/etc/profile.d/"
            CONDA_CHANGEPS1=false conda activate base
            \export PATH="/home/zhaosong/anaconda3/bin:$PATH"
    unset __conda_setup
    # <<< conda init <<<
  5. Do not forget to run $ source .bashrc to make the changes take effect. Otherwise, you may encounter errors when you run ipython or jupyter.
  6. If you meet the above error, you also first need to check the PATH environment variable’s value, you should make sure the anaconda bin directory path locate at beginning of the PATH value.
    ~$ echo $PATH
  7. If everything is correct, run python in a terminal, you can see Anaconda in the output text.
    ~$ python
    Python 3.7.1 (default, Dec 14 2018, 19:28:38) 
    [GCC 7.3.0] :: Anaconda, Inc. on linux
    Type "help", "copyright", "credits" or "license" for more information.
  8. Now run jupyter notebookcommand in a terminal, it will start up a web server and you can access it with URL http://localhost:8888/tree.
    $ jupyter notebook
    [I 22:21:57.057 NotebookApp] Writing notebook server cookie secret to /run/user/1000/jupyter/notebook_cookie_secret
    [I 22:21:57.234 NotebookApp] JupyterLab extension loaded from /home/zhaosong/anaconda3/lib/python3.7/site-packages/jupyterlab
    [I 22:21:57.234 NotebookApp] JupyterLab application directory is /home/zhaosong/anaconda3/share/jupyter/lab
    [I 22:21:57.235 NotebookApp] Serving notebooks from local directory: /home/zhaosong
    [I 22:21:57.235 NotebookApp] The Jupyter Notebook is running at:
    [I 22:21:57.236 NotebookApp] http://localhost:8888/?token=a1ccb7865e275163dbd751856698a601f6f69feb2627b266
    [I 22:21:57.236 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [C 22:21:57.254 NotebookApp] 
        To access the notebook, open this file in a browser:
        Or copy and paste one of these URLs:

1.2 Windows.

  1. Double click the installation file and follow the wizard steps to install.
  2. When the installation is complete, the installer will add the anaconda bin directory in the PATH system environment variable.
  3. Open a dos window and run the python command, if you see something like below, it means anaconda has been installed successfully in your Windows.
    C:> python
    Python 3.7.1 (default, Dec 14 2018, 19:28:38) 
    [GCC 7.3.0] :: Anaconda, Inc. on windows
    Type "help", "copyright", "credits" or "license" for more information.
  4. If you have installed another python version before, and the output does not contain Anaconda, you need to check the PATH system environment variable, to check whether anaconda installation path is included at the beginning of the PATH variable value or not.

1.3 macOS.

  1. Install anaconda on macOS is very similar to Windows.
  2. The difference is that the downloaded file is a .pkg file.
  3. Double click the .pkg file to install it.
  4. After installation, the bin folder ( anaconda executable file saved folder  ) in the anaconda installation directory will be added to /Users/$USER/.bash_profile automatically.
  5. To make sure the PATH value change take effect, run source .bash_profile command in a terminal.
  6. To verify the anaconda installation is successful, open a terminal and run python or ipython command, then you should see anaconda in the output text.
  7. If it shows an error message, you should run env command in terminal to check the PATH environment variable value, to see whether it’s value contains the anaconda bin folder or not.
0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x