Like Java, you will need at most only two pieces of software: the Python environment and some text editor. Depending on your operating system, you'll use different instructions to install Python.
Windows
Mac OSX
Linux
If you encounter problems trying to set up Python, contact Marty Stepp (stepp) for help and suggestions.
Windows does not come with Python pre-installed, so you will have to download and install it.
Step 1. Install Python
Python v3.2.2 InstallerClick the link above to download the Python installer. Once downloaded, run the program to install Python.
Step 2. Run The IDLE Editor
IDLE is an interpreter/editor combo called found under "Start -> Programs -> Python 3.2.2 -> IDLE (Python GUI)". To create a new Python script, go to "File -> New Window" (CTRL+N). Here you can type out your Python code, save it, and then run it by selecting "Run -> Run Module" (F5). A benefit of the IDLE environment is that you can test Python commands in the Python Shell window ("Run -> Python Shell"), which contains the Python interactive interpreter.
To use the Python interpreter alone, run "Start -> Programs -> Python 3.2.2 -> Python (command line)". Here you can type Python commands into the window interactively.
Python comes pre-installed on Macs. However, it is often an older version, and it doesn't come bundled with an editor. We recommend one of two choices:
If you choose route 1, instructions are in the link provided. If you choose route 2, we recommend installing the Smultron text editor:
Step 1. Install Smultron
Smultron HomepageFirst, go to the Smultron Homepage and download the Latest Version from the Download section in the top right.
Step 2. Configure Smultron for Python
Although Smultron will work fine without configuration, a single configuration option will make life a little easier.
Go to "Tools -> Handle Commands -> Show Commands Window" (⌘B) and select "Other" under the Collections column. Next, click "New Command" in the top right. For a name, put "Run Python Script". In the box below, paste the following:
#!/bin/bash osascript <<-EOF tell app "Terminal" launch activate do script "python '$(echo %%p)'" end tell EOFOptionally, double-click the shortcut field to create a shortcut to run your script. If everything was done correctly, it should look like this screenshot.
Step 3. Using Your Editor
Smultron is easy to use. First, create a new document (⌘N). Next, save your empty document (⌘S) as a .py file -- for example, "greeneggs.py". Finally, type your Python code as you normally would and it will show up with syntax highlighting.
To run your Python code, select "Tools -> Commands -> Other -> Run Python Script", or optionally use your shortcut keybind if you made one in the previous step.
Step 4. Using the Python Interpreter
To use the Python Interpreter, open Terminal and type
pythonto start it. Terminal is located in "Applications -> Utilities -> Terminal".
Chances are, if you're using a Linux distribution you probably have Python already. To check, open a Terminal (aka Command Line) and type python
. If you already have Python installed, this will pull up a Python Interpreter; otherwise, follow the instructions to get Python on this page.