Introduction to Python
Part 0: Installing Python and Anaconda
By Arun Ramamurthy
Introduction
In this mini-tutorial, you will learn how to install Python (a computer programming language) and Anaconda (a distribution that automatically installs Python and a bunch of auxillary packages useful for data science). This is in preparation for py1, SAAS’s crash course on Python for data science.
Installing Python & Anaconda
For Mac
- Visit the Anaconda website and click the Mac icon. Install the Python 3.6 version of Anaconda.
- Run the downloaded .pkg file, and begin to step through the installation process. On the
Destination Select
stage, highlight Install for me only
before continuing.
- When finished, Anaconda, Python, pip, and other Python libraries will be installed on your machine. To test your installation, navigate to the
anaconda3
folder, usually found by typing the following into your Terminal and pressing ENTER
:
cd ~/anaconda3/
Then, run the conda command in the /bin/
folder by typing the following into your Terminal and pressing Enter
:
./bin/conda list
If a list of packages is displayed on your screen, Anaconda installed successfully! 4. If Anaconda installed successfully, you’ll want to add Anaconda commands to what’s called your PATH. This allows you to run Anaconda commands, like conda
, pip
, and ipython
without navigating to your Anaconda installation folder first. To refresh your path, and therefore add Anaconda to it, type the following into your Terminal:
source ~/.bash_profile
- Next, we’ll need to install iPython so that you can view iPython notebooks, such as those hosted in the SAAS Crash Courses repository. First, run the following conda commands in your Terminal:
conda update conda
conda update ipython
conda update jupyter
- You should now be able to launch and interact with iPython notebook files. To do so, navigate to the directory containing iPython files with:
cd /your/ipython/directory/here
and then run:
jupyter notebook
For Windows
(NOTE: CURRENTLY UNTESTED INSTALLATION GUIDE)
- Visit the Anaconda website and click the Windows icon. Install the Python 3.6 version of Anaconda.
- Run the downloaded .exe file, and begin to step through the installation process. On the
Destination Select
stage, highlight Install for me only
before continuing. We recommend NOT adding Anaconda to your path, as it can conflict with other applications.
- When finished, Anaconda, Python, pip, and other useful Python libraries will be installed on your machine. To test your installation, search for the Anaconda Navigator application and run it.
- Anaconda Navigator should include iPython/Jupyter so that you can view iPython notebooks, such as those hosted in the SAAS Crash Courses repository. You should now be able to launch and interact with iPython notebook files. To do so, navigate to the directory containing iPython files and launch them using Anaconda Navigator.
For Linux
- Visit the Anaconda website and click the Linux icon. Install the Python 3.6 version of Anaconda.
- Go to your Downloads folder, and run the downloaded .sh file with
bash ./<Anaconda_installer_name.sh>
, and begin to step through the installation process. This will involve reading a Terms and Conditions document (press ENTER
to read through) and agreeing to a installation location. Make sure to indicate yes
to prepending the Anaconda installation to your PATH.
- When finished, Anaconda, Python, pip, and other Python libraries will be installed on your machine. To test your installation, list the packages that Anaconda has installed on your machine with:
conda list
- Next, we’ll need to install iPython so that you can view iPython notebooks, such as those hosted in the SAAS Crash Courses repository. First, run the following conda commands in your Terminal:
conda update conda
conda update ipython
conda update jupyter
- You should now be able to launch and interact with iPython notebook files. To do so, navigate to the directory containing iPython files with:
cd /your/ipython/directory/here
and then run:
jupyter notebook
Additional Readings