AADL Logo Advanced Aircraft Design Lab

Royal Military College of Canada

Python Setup Guide

  • Author: Advanced Aircraft Design Lab (AADL) at the Royal Military College of Canada
  • Revision: 1.0
  • Date 30-01-2012

This guide is intended to help you setup a python programing environment on a Windows 7 machine suitable for engineering programming tasks.

Resources

On the Web

Here are some links to useful python learning resources:

  • Numpy for Matalb Users
    • A chart which compares common Matlab functions with their numpy equivalents.
  • Learn Python the Hard Way
    • This is a good, free, online textbook which allows you to work through a series of tutorials.
  • Python Style Guide
    • The definitive style guide. May not be completely understandable for new users
    • Co-authored by python’s Benevolent Dictator for Life, Guido van Rossum.

Hard Copy

These books are available from the ACD Lab.

  • Downey, A., Elkner, J. and Meyers, C., 2009. “Learning With Python: How to Think Like a Computer Scientist.” SoHo Books: USA.
    • Introductory text.
    • Poor reference book, should be read cover to cover
  • Langtangen, H. P., 2008. “Python Scripting for Computational Sciences.” Springer: Berlin
    • Advanced topics.
    • Good reference book.

Software Setup

Python

  • Version: Python 2.7 NOT Python 3.*.
    • Use the 32 bit version for compatibility.
  • Link

  • Installation Instructions:

    Install in the default directory <C:\Python27\> You will have to add python to the system path:

    1. Right click on ‘My Computer’
    2. Click on properties
    3. Click on ‘Advanced system settings” on the bottom left of the window
    4. Click on ‘Environment variables’
    5. In the second window, scroll down and select ‘Path’
    6. Click Edit
    7. Keep all the text. Add a semicolon (‘;’) then add the path to the python installation directory (Typically C:Python27)
    8. Click ok
    9. Click ok
    10. Click ok

numpy

  • Version: 32 bit for python 2.7
  • Note Used to make python work like Matlab.
  • Link

matplotlib

  • Version: 32 bit for python 2.7
  • Note: Used to plot things.
  • Link

wxpython

  • Version: 32 bit for python 2.7
  • Note: Used to make GUI’s. Needed to install Dr. Python.
  • Link

Dr. Python

  • Version: Any (Most recent preferred)

  • Note: Preferred python development environment and editor.

  • Link

  • Installation Instructions:

    1. Extract into $HOME\Downloads\ where $HOME is: C:\Users\\username\

    2. Open windows power shell or command prompt if available

    3. Navigate to $HOME\Downloads\:

      >> python setup.py build
      >> python setup.py install
    4. Create a desktop shortcut to: C:\Python27\Lib\site-packages\drpython\drpython.py

    5. The icon for Dr. python is located in: C:\Python27\Lib\site-packages\drpython\bitmaps

gedit

  • Version: Any (Most recent preferred)

  • Note: Easy to install text editor.
    • Unlike Dr. Python, you cannot run python scripts from within gedit
    • Note the warning under the windows section in the following link from Learn Python the Hard Way
  • Link

Bonus packages

You do not need these packages but they may be necessary for some specific tasks

scipy

  • Version: 32 bit for python 2.7

  • Note: Used to access numerical recipes like in Matalb
    • Most of the scipy tools are not suitable for paralell programming and their use in AADL code is strongly discouraged
  • Link

Testing python

Testing python from the command prompt

  1. Open a command prompt or windows power shell.:

    >>python
  2. in python type:

    >> import numpy as np
    >> import matplotlib.pyplot as plt
    >> a=np.array([1.0,2.0,3.0,4.0])
    >> b=a**2
    >> plt.plot(a,b)
    >> plt.show()
  3. A plot window with a parabolic curve should appear. If any errors occur along the you made a mistake.

  4. Close the plot window.:

    >>exit()
  1. Close the command prompt.

Testing Dr. Python

  1. Open Dr. Python
  2. Copy the same code as before and then click the “play” button. You will have to save your script to run it.
  3. A plot window with a parabolic curve should appear. If any errors occur along the you made a mistake.
This web site is not an official publication of the Royal Military College of Canada nor the Department of National Defence
Ce site web n’est pas une publication officielle du Collége militaire royal du Canada ni du Ministère de la défense nationale