Anaconda Python Distribution
A naconda 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.
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
- 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.
- 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.
- Click the continue button.
- Optional: To install PyCharm for Anaconda, click on the link to https://www.anaconda.com/pycharm.
- 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//anaconda 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 /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 /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 init first.
Note: conda init is available in conda versions 4.6.12 and later.
- Verify your installation.
Installing on Linux
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:
Task:
You have to explore the functionality available in Jupyter notebook and also try to remember some of the shortcuts available.