A Complete Guide to Anaconda Installation

Omprakash Sah
10 min readDec 15, 2020

--

Anaconda Python Distribution

Anaconda is an open-source package manager, environment manager, and distribution of the Python and R programming languages. It is commonly used for large-scale data processing, scientific computing, and predictive analytics, serving data scientists, developers, business analysts, and those working in DevOps.

Anaconda offers a collection of over 720 open-source packages, and is available in both free and paid versions. The Anaconda distribution ships with the conda command-line utility.

Anaconda Navigator

Why Anaconda?

  • User level install of the version of python you want
  • Able to install/update packages completely independent of system libraries or admin privileges
  • conda tool installs binary packages, rather than requiring compile resources like pip — again, handy if you have limited privileges for installing necessary libraries.
  • More or less eliminates the headaches of trying to figure out which version/release of package X is compatible with which version/release of package Y, both of which are required for the install of package Z
  • Comes either in full-meal-deal version, with numpy, scipy, PyQt, spyder IDE, etc. or in minimal / alacarte version (miniconda) where you can install what you want, when you need it
  • No risk of messing up required system libraries

Anaconda Installation on Windows

Steps:

  • Download the Anaconda installer.
  • RECOMMENDED: Verify data integrity with SHA-256. For more information on hashes, see What about cryptographic hash verification?
  • Double click the installer to launch.
    Note:
    If you encounter any issues during installation, temporarily disable your anti-virus software during install, then re-enable it after the installation concludes. If you have installed for all users, uninstall Anaconda and re-install it for your user only and try again.
  • Click Next.
  • Read the licensing terms and click I Agree.
  • Select an install for “Just Me” unless you’re installing for all users (which requires Windows Administrator privileges).
  • Select a destination folder to install Anaconda and click Next.
    Note: Install Anaconda to a directory path that does not contain spaces or unicode characters.
    Note: Do not install as Administrator unless admin privileges are required.
  • Choose whether to add Anaconda to your PATH environment variable. We recommend not adding Anaconda to the PATH environment variable, since this can interfere with other software. Instead, use Anaconda software by opening Anaconda Navigator or the Anaconda Command Prompt from the Start Menu.
  • Choose whether to register Anaconda as your default Python. Unless you plan on installing and running multiple versions of Anaconda or multiple versions of Python, accept the default and leave this box checked.
  • Click the Install button. If you want to watch the packages Anaconda is installing, click Show Details.
  • Click the Next button.
  • Optional: To install PyCharm for Anaconda, click on the link to https://www.anaconda.com/pycharm.

Note: Or to install Anaconda without PyCharm, click the Next button.

  • After a successful installation you will see the “Thanks for installing Anaconda” dialog box:
  • If you wish to read more about Anaconda Cloud and how to get started with Anaconda, check the boxes “Learn more about Anaconda Cloud” and “Learn how to get started with Anaconda”. Click the Finish button.
  • After your install is complete, verify it by opening Anaconda Navigator, a program that is included with Anaconda. From your Windows Start menu, select the shortcut Anaconda Navigator. If Navigator opens, you have successfully installed Anaconda.

Installing on macOS

You can install Anaconda using either the graphical installer (“wizard”) or the command line (“manual”) instructions below. If you are unsure, choose the graphical install.

Steps:

macOS graphical install

  • OR, click the Change Install Location button to install in another location (not recommended). On the Destination Select screen, select Install for me only.
    Note: If you get the error message “You cannot install Anaconda in this location,” reselect Install for me only.
  • Or to install Anaconda without PyCharm, click the Continue button.
  • A successful installation displays the following screen:
  • Verify your installation.

Using the command-line install

  • Download the graphical macOS installer for your version of Python.
  • RECOMMENDED: Verify data integrity with SHA-256. For more information on hashes, see What about cryptographic hash verification?
    Open a terminal and run the following:
    shasum -a 256 /path/filename
  • Note: Replace /path/filename with your installation’s path and filename.
  • Install for Python 3.7 or 2.7:
    For Python 3.7 enter the following:bash ~/Downloads/Anaconda3-2020.02-MacOSX-x86_64.sh
  • For Python 2.7, open the Terminal.app or iTerm2 terminal application and then enter the following:
    bash ~/Downloads/Anaconda2-2019.10-MacOSX-x86_64.sh
  • Note: Include the bash command regardless of whether or not you are using the Bash shell.
    Note: Replace ~/Downloads with your actual path and Anaconda3-2020.02-MacOSX-x86_64.sh with actual name of the file you downloaded.
  • The installer prompts “In order to continue the installation process, please review the license agreement.” Click Enter to view the license terms.
  • Scroll to the bottom of the license terms and enter yes to agree to them.
  • The installer prompts you to Press Enter to confirm the location, Press CTRL-C to cancel the installation or specify an alternate installation directory. If you confirm the default location, it will display PREFIX=/home/<user>/anaconda<2 or 3> and continue the installation.
    Note: Unlike the graphical install, installing the shell file will place it in ~/anaconda by default, not ~/opt. This is due to limitations with installing .pkg files on macOS Catalina.
    Installation may take a few minutes to complete.
    Note: We recommend you accept the default install location. Do not choose the path as /usr for the Anaconda/Miniconda installation.
  • The installer prompts “Do you wish the installer to initialize Anaconda3 by running conda init?” We recommend “yes”.
    Note: 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 <path to conda>/bin/activate and then run conda init.
    Note: If you are on macOS Catalina, the new default shell is zsh. You will instead need to run source <path to conda>/bin/activate followed by conda init zsh.
  • Installer displays “Thank you for installing Anaconda!”
  • Optional: The installer describes the partnership between Anaconda and JetBrains and provides a link to install PyCharm for Anaconda at https://www.anaconda.com/pycharm.
  • Close and open your terminal window for the Anaconda installation to take effect.
  • To control whether or not each shell session has the base environment activated or not, run conda config --set auto_activate_base False or True. To run conda from anywhere without having the base environment activated by default, use conda config --set auto_activate_base False. This only works if you have run conda initfirst.
    Note: conda init is available in conda versions 4.6.12 and later.
  • Verify your installation.

Installing on Linux

Steps:

  • In your browser, download the Anaconda installer for Linux.
  • Optional: Verify data integrity with MD5 or SHA-256. (For more information on hashes, see cryptographic hash validation.) Run the following: md5sum /path/filename OR: sha256sum /path/filename
  • Verify results against the proper hash page to make sure the hashes match.

Enter the following to install Anaconda for Python 3.6:

bash ~/Downloads/Anaconda3–4.4.0-Linux-x86_64.sh OR

Enter the following to install Anaconda for Python 2.7:

bash ~/Downloads/Anaconda2–4.4.0-Linux-x86_64.sh

NOTE: You should include the bash command regardless of whether you are using Bash shell. NOTE: Replace actual download path and filename as necessary. NOTE: Install Anaconda as a user unless root privileges are required.

  • The installer prompts “In order to continue the installation process, please review the license agreement.” Click Enter to view license terms.
  • Scroll to the bottom of the license terms and enter yes to agree to them.
  • The installer prompts you to click Enter to accept the default install location, press CTRL-C to cancel the installation, or specify an alternate installation directory. If you accept the default install location, the installer displays ’PREFIX=/home/”user”/anaconda”2 or 3"’ and continues the installation. It may take a few minutes to complete.

The installer prompts “Do you wish the installer to prepend the Anaconda”2 or 3" install location to PATH in your /home/”user”/.bashrc ?” We recommend yes.

NOTE: If you enter “no”, you will need to manually specify the path to Anaconda when using Anaconda. To manually add the prepended path, edit file .bashrc to add ~/anaconda”2 or 3"/bin to your path manually using:

  • export PATH=”/home/”user”/anaconda”2 or 3"/bin:$PATH” Replace /home/”user”/anaconda”2 or 3" with the actual path.
  • The installer finishes and displays “Thank you for installing Anaconda”2 or 3"!”
  • Close and open your terminal window for the installation to take effect, or you can enter the command source ~/.bashrc.

Enter conda list. If the installation was successful, the terminal window should display a list of installed Anaconda packages.

NOTE: Power8 users: Navigate to your Anaconda directory and run this command: conda install libgfortran

What is Jupyter notebook?

The notebook is a web application that allows you to combine explanatory text, math equations, code, and visualizations all in one easily sharable document.

Notebooks have quickly become an essential tool when working with data. You’ll find them being used for data cleaning and exploration, visualization, machine learning, and big data analysis. Typically you’d be doing this work in a terminal, either the normal Python shell or with IPython. Your visualizations would be in separate windows, any documentation would be in separate documents, along with various scripts for functions and classes. However, with notebooks, all of these are in one place and easily read together.

Notebooks are also rendered automatically on GitHub. It’s a great feature that lets you easily share your work. There is also http://nbviewer.jupyter.org/ that renders the notebooks from your GitHub repo or from notebooks stored elsewhere.

How notebook works?

Jupyter notebooks grew out of the IPython project started by Fernando Perez. IPython is an interactive shell, similar to the normal Python shell but with great features like syntax highlighting and code completion. Originally, notebooks worked by sending messages from the web app (the notebook you see in the browser) to an IPython kernel (an IPython application running in the background). The kernel executed the code, then sent it back to the notebook. The current architecture is similar, drawn out below.

The central point is the notebook server. You connect to the server through your browser and the notebook is rendered as a web app. Code you write in the web app is sent through the server to the kernel. The kernel runs the code and sends it back to the server, then any output is rendered back in the browser. When you save the notebook, it is written to the server as a JSON file with a .ipynb file extension.

The great part of this architecture is that the kernel doesn’t need to run Python. Since the notebook and the kernel are separate, code in any language can be sent between them. For example, two of the earlier non-Python kernels were for the R and Julia languages. With an R kernel, code written in R will be sent to the R kernel where it is executed, exactly the same as Python code running on a Python kernel. IPython notebooks were renamed because notebooks became language agnostic. The new name Jupyter comes from the combination of Julia, Python, and R. If you’re interested, here’s a list of available kernels.

Another benefit is that the server can be run anywhere and accessed via the internet. Typically you’ll be running the server on your own machine where all your data and notebook files are stored. But, you could also set up a server on a remote machine or cloud instance like Amazon’s EC2. Then, you can access the notebooks in your browser from anywhere in the world.

Installing Jupyter Notebook

By far the easiest way to install Jupyter is with Anaconda. Jupyter notebooks automatically come with the distribution. You’ll be able to use notebooks from the default environment.

To install Jupyter notebooks in a conda environment, use conda install jupyter notebook.

Jupyter notebooks are also available through pip with pip install jupyter notebook.

Launching the notebook server

To start a notebook server, enter jupyter notebook in your terminal or console. This will start the server in the directory you ran the command in. That means any notebook files will be saved in that directory. Typically you’d want to start the server in the directory where your notebooks live. However, you can navigate through your file system to where the notebooks are.

When you run the command (try it yourself!), the server home should open in your browser. By default, the notebook server runs at http://localhost:8888. If you aren’t familiar with this, localhost means your computer and 8888 is the port the server is communicating on. As long as the server is still running, you can always come back to it by going to http://localhost:8888 in your browser.

If you start another server, it’ll try to use port 8888, but since it is occupied, the new server will run on port 8889. Then, you’d connect to it at http://localhost:8889. Every additional notebook server will increment the port number like this.

If you tried starting your own server, it should look something like this:

Jupyter Notebook Console

Task:

You have to explore the functionality available in Jupyter notebook and also try to remember some of the shortcuts available.

--

--