Programming with Python: Setup

Obtain lesson materials

  1. Download python-novice-inflammation-data.zip and python-novice-inflammation-code.zip.
  2. Create a folder called swc-python on your Desktop.
  3. Move downloaded files into this newly created folder.
  4. Unzip the files.

You should now see two new folders called data and code in your swc-python directory on your Desktop.

Running Python

If you’re using macOS, you should run the Anaconda Navigator (installed in /Users/<username>/anaconda3/bin by default unless you’ve moved it to Applications) and then go to Environments -> base(root) ‘Play’ button -> ‘Open Terminal’. This gives you a terminal that has all the shell commands available that you’ve learnt already but also allows you to run python as well.

drawing

If you’re using Windows, you should run git-bash as you did for the shell lesson. After that, you need to enter the following commands:

export PATH="/c/Users/$USERNAME/AppData/Local/Continuum/anaconda3/Scripts/:/c/Users/$USERNAME/AppData/Local/Continuum/anaconda3/:$PATH"
export PATH="/c/ProgramData/Anaconda3/Scripts/:/c/ProgramData/Anaconda3/:$PATH"

The first line is if you installed Anaconda 3 as a user, the second is if you installed it as an admin. If you’re unsure which you did, put in both!

If you installed Anaconda 3 to a non default directory then you will need a similar export PATH= command, to reflect the install location.

Whether you are on macOS or Windows you should now be at a Shell prompt that is capable of running Python. You should now navigate to your swc-python directory:

$ cd ~/Desktop/swc-python/data

Start IPython interpreter

IPython is an alternative interpreter to the vanilla python interpreter. It provides an interactive command-line based interpreter with various convenience features and commands. You should have IPython on your system if you installed Anaconda Distribution.

To start using IPython from the prompt, execute:

$ ipython