In this tutorial, we will set up a scientific Python computing environment using the Anaconda python distribution by Continuum Analytics.
As is true in human language, there are hundreds of computer programming languages. While each has its own merit, the major languages for scientific computing are C, C++, R, MATLAB, Python, Java, Fortran and Julia. MATLAB, Python and Julia are similar in syntax and typically read as if they were written in plain English. This makes all three languages a useful tool for teaching but they are also very powerful languages and are very actively used in real-life research. MATLAB is proprietary while Python and Julia are open source. A benefit of being open source is that anyone can write and release packages. For science, there are many wonderful community-driven packages such as the Python packages NumPy, SciPy, scikit-image, and Pandas just to name a few.
There are two dominant versions of Python used for scientific computing, Python 2.7 and Python 3.8. However, as of 2020, Python 2.7 is no longer supported and Python 3.8 is the recommended version to use, which is why we are using this version in these tutorials.
There are several scientific Python distributions available for MacOS, Windows, and Linux. The two most popular, Enthought Canopy and Anaconda are specifically designed for scientific computing and data science work. For this course, we will use the Anaconda Python 3.8 distribution. To install the correct version, follow the instructions below.
Navigate to the Anaconda download page and download the Python 3.8 graphical installer.
Launch the installer and follow the onscreen instructions.
Congratulations! You now have the beginnings of a scientific Python distribution.
It will be useful to have access to a UNIX command line to launch Jupyter notebooks, make and move directories, as well as to install extra packages for Python through the conda package manager. For those on OSX, we will use the built-in Terminal.app program. For those using Linux, we will assume you know what we are talking about and have some familiarity with the command line.
Windows does not come with a UNIX command line interface. To install such an interface, we recommend using GitBash. To install, please navigate to their download page and follow the download instructions. Please set the following settings upon installation.
Adjusting your PATH environment -> Use Git from Windows Command Prompt.
Configuring the line ending conversions -> Checkout Windows-style, commit unix style line endings.
We will not be using the git version control system, so these preferences are less important.
Once installed, you will be able to launch a UNIX compatible terminal interface wherever you are in your operating system by right clicking on the desktop or windows explorer window and selecting "Run GitBash here".
Please see the python syntax tutorial for a primer on using the UNIX command line.
For this course (and your coding in 'real life'), it will help if you follow a specific directory structure for your code and data. During this course, we will write a lot of code that will load in data. To ensure that everyone's code runs properly, it is essential that you all set up your directories in the same way. All code we write will assume that you have the following directory structure:
In your home directory, make a new folder named
bootcamp. On MacOS and Linux, your home directory will be in
/Users/YOUR_USERNAME/. On Windows, your home directory will be in
All code files you write during the course will be saved in this
bootcamp folder, make a folder named
data, into which all data files from the course will be saved.
If you have followed all of these steps successfully, you should have a complete setup for scientific computing in Python! You are now ready to start coding! We will be using Jupyter Notebooks, which allow us to write code, text, and math into a single document. In fact, this (and all other tutorials) were written in Jupyter notebooks. The next tutorial will introduce you to Jupyter Notebooks and how to use them.