Getting Up and Running with Python

When just starting out with Python, it can be extremely difficult to get things up and running smoothly. You should have a reasonably high chance of success if you follow these instructions; however, there are still countless things that could go wrong, so if something doesn’t work for you and you work through a solution, please post the problem and solution in the comments so that others can benefit.

 

Mac

  1. Go to http://continuum.io/downloads, scroll down to the downloads section and download the installer for the appropriate version.

  2. Find the Anaconda .pkg file in your Downloads folder, double click it, and follow the instructions on your screen. Note: There is a bug in the OS X installer that will require you to click “Install for me only.” at some point during the installation. If you run into issues or want more info, check out http://docs.continuum.io/anaconda/install.html#mac-install.

  3. Look on your desktop for the Anaconda Launcher Icon launcher and double click it. Note: if it is not on your desktop, search for “Launcher” to find it. A search for anaconda will only turn up the installer .pkg file.

  4. Click the blue launch button launcher next to ipython-notebook to launch your IPython Notebook web server.

    Some people experienced problems when running 64bit Anaconda on Mac OS X. If you get the following error: ValueError: unknown locale: UTF-8, please update your locale setting as advised here .

  5. Go to http://127.0.0.1:8888/ using your browser of choice. IPython Notebook should be running. If it isn’t running there, try http://127.0.0.1:8889/ or http://127.0.0.1:8890/.

 

  1. Click the “New Notebook” button on the right.

  2. Click on “Untitled0” at the top and type in “My First IPython Notebook” (or whatever you want) to rename your notebook.

  3. You should see a box with In [ ]: in it. Click to the right of In [ ]: and copy and paste the following code:

In [1]:
for i in range(4):
print i, " I am ready to do some statistical learning in Python!"
if i==0: print '"R" you surprised that Python starts its index at 0 instead of 1?'
 
0  I am ready to do some statistical learning in Python!
"R" you surprised that Python starts its index at 0 instead of 1?
1 I am ready to do some statistical learning in Python!
2 I am ready to do some statistical learning in Python!
3 I am ready to do some statistical learning in Python!
  1. Click on the run button play and check out the output. Great success! [ hopefully :) ]
  2. If you want to open up an existing IPython Notebook, click on the IP[y]: Notebook logo and drag/drop the file onto the list of notebooks or click the “click here” text to browse your filesystem and select the file. You can download the first IPython Notebooks in our series here .

 

Linux (Ubuntu)

  1. Go to http://continuum.io/downloads, scroll down to the downloads section and download the appropriate installer for your architecture.
  2. Open a terminal and navigate to the package you just downloaded.
  3. Run chmod +x Anaconda-<version>.sh
  4. Then run ./Anaconda-<version>.sh. The installer will begin running.
    1. Hit Enter to view the License agreement. Press Space to continue reading.
    2. Type yes to accept this license agreement. Then hit Enter.
    3. Hit Enter if the default installation directory is fine to install into. Anaconda will begin its installation.
    4. Type yes to add the Anaconda PATH to your ~/.bashrc. Then hit Enter.
  5. To start the IPython Notebook server, run the following commmand from a new terminal:$ ipython notebook
  6. Go to http://127.0.0.1:8888/ using your browser of choice. IPython Notebook should be running. If it isn’t running there, try http://127.0.0.1:8889/ or http://127.0.0.1:8890/.

 

  1. Click the “New Notebook” button on the right.
  2. Click on “Untitled0” at the top and type in “My First IPython Notebook” (or whatever you want) to rename your notebook.
  3. You should see a box with In [ ]: in it. Click to the right of In [ ]: and copy and paste the following code:
In [2]:
for i in range(4):
print i, " I am ready to do some statistical learning in Python!"
if i==0: print '"R" you surprised that Python starts its index at 0 instead of 1?'
 
0  I am ready to do some statistical learning in Python!
"R" you surprised that Python starts its index at 0 instead of 1?
1 I am ready to do some statistical learning in Python!
2 I am ready to do some statistical learning in Python!
3 I am ready to do some statistical learning in Python!
  1. Click on the run button play and check out the output. Great success! [ hopefully :) ]
  2. If you want to open up an existing IPython Notebook, click on the IP[y]: Notebook logo and drag/drop the file onto the list of notebooks or click the “click here” text to browse your filesystem and specify the file. You can download the first IPython Notebooks in our series here .

 

Windows

  1. Go to http://continuum.io/downloads, scroll down to the downloads section and download the Windows installer for the appropriate architecture (64bit or 32bit).
  2. Find the Anaconda-<version>-Windows-x86_<arch>.exe file in your Downloads folder, double click it, and follow the instructions on your screen. Make sure that you check the box ’Add Anaconda to the System Path’.
  3. Once Anaconda is installed you can find an Anaconda folder in the Windows start menu.
  4. Click on IPython (Py 2.7) Notebook; this will open a terminal window and shortly thereafter a new browser window should appear that shows the IP[y]: Notebook logo on the top left:

 

  1. Click the “New Notebook” button on the right.
  2. Click on “Untitled0” at the top and type in “My First IPython Notebook” (or whatever you want) to rename your notebook.
  3. You should see a box with In [ ]: in it. Click to the right of In [ ]: and copy and paste the following code:
In [3]:
for i in range(4):
print i, " I am ready to do some statistical learning in Python!"
if i==0: print '"R" you surprised that Python starts its index at 0 instead of 1?'
 
0  I am ready to do some statistical learning in Python!
"R" you surprised that Python starts its index at 0 instead of 1?
1 I am ready to do some statistical learning in Python!
2 I am ready to do some statistical learning in Python!
3 I am ready to do some statistical learning in Python!
  1. Click on the run button play and check out the output. Great success! [ hopefully :) ]
  2. If you want to open up an existing IPython Notebook, click on the IP[y]: Notebook logo and drag/drop the file onto the list of notebooks or click the “click here” text to browse your filesystem and specify the file. You can download the first IPython Notebooks in our series here .

This post was inspired from the StatLearning MOOC by Stanford.

New Call-to-action