PYTHON installation

In order to learn python programming we need the python language intepreter installed. Additionally we need some other resources, like ipython and a number of extra functionality for scientific research (don't worry, we will cover this later). First, you have to navigate down to the section describing the installation of python on your system:
You will early on be confused about python being distributed in two different versions; Python2 and Python3. You will not find alot of differences between the two versions in your python journey, but one deserves to be highlighted already at this stage:
Some third-party modules (packages) are not supported in Python3
This means that if you want to use external modules made by others, they may not be compatible with your current Python3 code. Most modules you will find describes what Python version(s) they support.
To avoid running into these issues during the course we will only be using Python2.
IPython provides a rich toolkit to help you make the most out of using Python interactively. First of all it comes with a rich and powerful version of the orignial python prompt with a lot of interactive features that will become clearer later in the course.
IPython also includes IPython Notebook which is a web-based python environment that is full of features. It offers a journal like perspective to your python coding and is very helpful for getting hands on python and will be used extensively in the first lectures. In fact, this text was written in IPython Notebook.
Check out some of the stuffs that has been done in this journal like editor here.
Windows
Python
Windows doesn't come with python preinstalled. The easiest way to get Python are through Pythonxy, which is a scientific-oriented Python Distribution, packaged with a number of scientific modules that we will use in the course.
-
Download pythonxy from this link.
-
Open the
Python(x,y)-2.7.5.0.exe file that you just downloaded.
-
Follow the installation instructions until you see this window
IPython
At this point we need to update the IPython that came with Pythonxy.
-
Now open the run command by holding down
while pressing R.
-
Type in cmd and hit Enter. This will open the command line prompt.
-
Type in cd C:/Python27/Scripts to navigate to this folder.
(Note: Use backslash instead of slash in the path).
-
Now type in pip.exe install ipython --upgrade and hit enter.
-
Now verify that you have the correct version of IPython using the ipython.exe --version command. If everything went OK you should see 1.0.0:
Pyzmq (Important!)
Pyzmq is a network protocol needed for the Notebook. We need to install it manually.
-
Download the pyzmq installer from this link
-
Open the file
pyzmq-2.2.0.win32-py2.7.msi and follow the instructions for installing it.
BioPython
Another import module not supplied with the Pythonxy distribution is BioPython which we will use later in the course.
-
Download the BioPython installer from this link.
-
Open the
biopython-1.62.win32-py2.7.exe file and follow the installation instructions.
Setting up a Desktop Shortcut
-
Now all we need is to create a shortcut to IPython Notebook. On your Desktop (or anywere you like) right click and select New and then Shortcut.
-
In the shortcut path type in C:/Python27/Scripts/ipython.exe notebook --notebook-dir="C:/Notebooks"
(You can set the path "C:/Notebooks" to whereever you want your course material to be. Again: use backslash!
-
Run the program from the newly created shortcut and celebrate the success!
Done!
If you have any troubles setting up everything, please stop by my office 060 in building 208.
MAC
Python
Python comes pre-installed on Mac OS X, but due to Apple's release cycle, it's often one or even two years old. The overwhelming recommendation of the "MacPython" community is to upgrade your Python by downloading and installing a newer version from the Python standard release page.
-
Download the latest Python2 release for your system to your desktop:
-
Open a terminal: /Applications/Utilities/Terminal
-
Navigate to Desktop by typing cd ~/Desktop/
-
Install Python2 by running either
hdiutil mount python-2.7.5-macosx10.3.dmg for 32-bit, or
hdiutil mount python-2.7.5-macosx10.6.dmg for 64-bit.
and then,
sudo installer -pkg "/Volumes/Python 2.7.5/Python.mpkg" -target /
GCC, Clang or XCode
For some of the scientific modules to work you need to install software to take care of C (another language).
[ This will solve the CLang error of Pandas and BioPython installation]
If you already installed XCode:
If you have manually installed XCode earlier, all you need to do is open XCode and hold down Command and press , . This will open up XCode preferences. Go to the Download tab at the top of the window and select "Command Line Tools" and click Install.
If you don't have XCode installed:
-
Download GCC from the following link, depending on your system:
-
Open the installer and follow the instructions
-
Once finished you should see this window
IPython and extras
The program easy_install comes with python and can be used to install additional Python2 packages. Open a terminal and type in:
sudo easy_install numpy
sudo easy_install tornado
sudo easy_install pyzmq
sudo easy_install pip
sudo easy_install biopython
sudo easy_install jinja2
Unfortunately easy_install does not contain the latest version of IPython that we will use in the course. Therefore use the newly installed pip to get it: sudo pip install ipython
Now, if everything went okay you should be able to run ipython notebook and see the following window:
To access the course material, you have to run the ipython notebook command from the notebook directory. Navigate to the notebook inside the course material directory using the cd command, eg:
cd ~/Documents/Courses/cbs-python/notebooks
Now open the notebook using
ipython notebook
inside this directory and you should see the following window if everything works OK.
If you have any troubles setting up everything, please stop by my office 060 in building 208.
Linux
Python
Python comes installed with all linux distributions worth mentioning.
IPython and extras
In Ubuntu/Debian systems run in the terminal:
sudo apt-get install python-pandas python-matplotlib python-numpy python-pip python-zmq python-tornado
In Fedora systems run in the terminal:
sudo yum install python-pandas python-matplotlib python-numpy python-pip python-zmq python-tornado
Now install IPython using pip:
sudo pip install ipython
Now check that it works by running ipython notebook in your terminal. You should see the following browser window popping up:
To access the course material and exercises you have to run the ipython notebook command from the notebook directory.
If you have any questions or problems during installation stop by my office 060 in 208 and I will try to help you out.