Linux set up Python (Anaconda)

From OpenHatch wiki

Download and install Anaconda

Linux ships with Python installed, but we will be using some additional modules that are not installed by default. We will be installing these. We will then make sure you can start a terminal and run Python from the command line.

To install all of them at once, we will install Anaconda. Anaconda includes the Python programming language and a bunch of different pieces of software that are useful for data science and analysis. Although the collection includes all free software, it is put together by a commercial company called Continuum Analytics.

To install Anaconda, you should:

  • Download and install Anaconda. Follow the link and click on the big blue Download Anaconda button in the top right corner. If you go to the main http://continuum.io page instead, the website will ask you for your email address when you log in. There's no reason to leave the checkbox marked saying that you want mail from Continuum.
  • On the next page, click on the link to download the version of Python 2.7 (not Python 3.0).
  • Once you have downloaded the installer, open a terminal and navigate to where you downloaded the installer. If you are not sure where it is, try typing
    cd ~/Downloads/
    to move to your Downloads folder, then ls to list the files so you can see if it is there. Once in the containing folder, type
    bash Anaconda-
    and then press tab to autocomplete the rest of the name of your downloaded file. Press enter to start the installer.
  • Use all of the defaults for installation unless you have a good reason not to.

More information

If you do not want to use the Anaconda installer, you can take a look at this page. However, set up will be significantly more difficult.

Test to make sure Python is working

  1. Start up a Terminal. You can find the Terminal application at Applications/Accessories/Terminal, or it may already be on your menu bar.

    This Terminal contains something called a command prompt. This command prompt is another way of navigating your computer and running programs -- just textually instead of graphically. We are going to be running Python and Python scripts from this command prompt.
  2. Test your Python install at the command prompt. Type
    python
    

    and hit enter. You should see something like

    Python 2.7.8 |Anaconda 2.1.0 (64-bit)| (default, Aug 21 2014, 18:22:21) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    Anaconda is brought to you by Continuum Analytics.
    Please check out: http://continuum.io/thanks and https://binstar.org
    >>> 
    
    • You just started Python! The >>> indicates that you are at a new type of prompt: a Python prompt. The command prompt lets you navigate your computer and run programs, and the Python prompt lets you write and run Python code interactively.
  3. To exit the Python prompt, type
    exit()
    
    and press Enter. This will take you back to the Linux command prompt.

Success!

You have tested your Python installation!