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.
- The anaconda installation is very simple and straightforward. The installation process on all three platforms ( Linux, Windows, macOS ) is very similar.
- 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.
- Anaconda Linux install file is just a .sh file, it is executable.
- First, open a terminal to run the command chmod +x Anaconda3-2018.12-Linux-x86_64.sh to add executable permission.
- Then run the Anaconda3-2018.12-Linux-x86_64.sh file to install anaconda.
- The installation process is very straightforward. It will download and install a lot of dependency libraries.
- Remember the anaconda3 installed directory that is printed on the screen during the installation process like below.
Anaconda3 will now be installed into this location: /home/jerry/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/home/jerry/anaconda3] >>> PREFIX=/home/jerry/anaconda3
- When the installation comes to the text Do you wish the installer to initialize Anaconda3, type yes to initialize it.
installation finished. Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no] [no] >>>
- After installation, you need to close the current terminal and open a new terminal to make the changes take effect.
./Anaconda3-2021.11-Linux-x86_64.sh: 489: [[: not found no change /home/jerry/anaconda3/condabin/conda no change /home/jerry/anaconda3/bin/conda no change /home/jerry/anaconda3/bin/conda-env no change /home/jerry/anaconda3/bin/activate no change /home/jerry/anaconda3/bin/deactivate no change /home/jerry/anaconda3/etc/profile.d/conda.sh no change /home/jerry/anaconda3/etc/fish/conf.d/conda.fish no change /home/jerry/anaconda3/shell/condabin/Conda.psm1 no change /home/jerry/anaconda3/shell/condabin/conda-hook.ps1 no change /home/jerry/anaconda3/lib/python3.9/site-packages/xontrib/conda.xsh no change /home/jerry/anaconda3/etc/profile.d/conda.csh modified /home/jerry/.bashrc ==> For changes to take effect, close and re-open your current shell. <==
- 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" else if [ -f "/home/zhaosong/anaconda3/etc/profile.d/conda.sh" ]; then . "/home/zhaosong/anaconda3/etc/profile.d/conda.sh" CONDA_CHANGEPS1=false conda activate base else \export PATH="/home/zhaosong/anaconda3/bin:$PATH" fi fi unset __conda_setup # <<< conda init <<<
- Do not forget to run
$ source .bashrcto make the changes take effect. Otherwise, you may encounter errors when you run
- 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 /home/zhaosong/anaconda3/bin:/use/bin:......
- 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.
- 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: file:///run/user/1000/jupyter/nbserver-13959-open.html Or copy and paste one of these URLs: http://localhost:8888/?token=a1ccb7865e275163dbd751856698a601f6f69feb2627b266
- Double click the installation file and follow the wizard steps to install.
- You should pay attention to the Select Installation Type wizard, there are 2 radio buttons behind the Install for, one is Just Me (recommended), the other is All Users(requires admin privileges).
- When you select the Just Me radio button, it will install anaconda under the user directory and it will not add the anaconda install path to the System Path environment variable, you should add it to the User variables Path environment variable, you can read the article How To Fix Python Can Not Be Recognized In Windows Command After Adding It To System Path Variable to learn more.
- When you select the All Users radio button and when the installation is complete, the installer will add the anaconda bin directory in the PATH system environment variable.
- 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.
- 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 the anaconda installation path is included at the beginning of the PATH variable value or not.
- If you do not know where the anaconda is installed on Windows, you can read the article How To Find Where Anaconda Python Is Installed.
- Install anaconda on macOS is very similar to Windows.
- The difference is that the downloaded file is a .pkg file.
- Double click the .pkg file to install it.
- After installation, the bin folder ( anaconda executable file saved folder ) in the anaconda installation directory will be added to /Users/$USER/.bash_profile automatically.
- To make sure the PATH value change take effect, run
source .bash_profilecommand in a terminal.
- To verify the anaconda installation is successful, open a terminal and run
ipythoncommand, then you should see anaconda in the output text.
- If it shows an error message, you should run
envcommand in terminal to check the PATH environment variable value, to see whether it’s value contains the anaconda bin folder or not.