How To Install Anaconda On Linux, Windows, MacOS Correctly

Anaconda is a scientific Python distribution which contains a lot of not often used scientific python libraries. If you want to do data analyze, scientific computing, you can install anaconda and use it to implement what you want. But after i install anaconda on Liunx, 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.

The anaconda installation is very simple and straight forward. The installation process on all the three platform is very similar. But before that you should download anaconda for your OS platform first.

After that follow below steps to install it on different OS platform.

1.1 Linux.

  1. Anacond linux install file is just a .sh file, it is executable.
  2. Open a terminal and run file to install.
  3. The installation process is very straight forward. 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 change 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 run $ source .bashrc to make the changes take effect. Otherwise you may encounter errors when you run ipython or jupyter.
  6. If you meet 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 terminal, it will startup 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:

    anaconda jupyter notebook web page

1.2 Windows.

  1. Double click the installation file and follow the wizard steps to install.
  2. When the installation complete, the installer will add anaconda bin directory in the PATH system environment variable.
  3. Open a dos window and run 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 other python version before, and the output do not contain Anaconda, you need to check 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 with Windows.
  2. The different 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 success, open a terminal and run python or ipython command, then you should see anaconda in the output text.
  7. If it shows error message, you should run env command in terminal to check the PATH env variable value, to see whether it’s value contains the anaconda bin folder or not.
(Visited 50 times, 1 visits today)
READ :   How To Install Python/Pip On Windows

Leave a Reply

Your email address will not be published. Required fields are marked *

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