Jump to content

Python on Windows: Difference between revisions

no edit summary
No edit summary
(22 intermediate revisions by 6 users not shown)
== Download and install Python ==
If you believe you already have Python installed, please let a staff member know before completing these steps.
<li>Go toClick http://python.org/downloadftp/python/ and download the latest version of Python 2.7 (.1/python-2.7.1.msi atand thechoose time"run" ofif writing)you have the option to. UnlessOtherwise, yousave knowit otherwiseto your Desktop, getthen theminimize "Windowswindows Installer"to see your versiondesktop, and notdouble click on it to start the "Windowsinstaller. X86-64Follow Installer"the installer instructions to versioncompletion.</li>
<li><b>Open a command prompt (we will be doing this multiple times, so make a note of how to do this!)</b>:
<li>Start* upOn aWindows commandVista promptor byWindows clicking7: click on the Start menu, clicking (the "Run..."Windows option,logo typingin "cmd",the andlower hittingleft enter. If you are using Windows Vista, you should click onof the Start menuscreen), type "<code>cmd"</code> into the Search field directly above the Start menu button, and click on "cmd" in the search results above the Search field.</li>
<li>Test your Python install by typing
* On Windows XP: click on the Start menu (the Windows logo in the lower left of the screen), click on "Run...", type <code>cmd</code> into the text box, and hit enter.
<br />
You now have what's 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.
<li>TestAt this <code>C:\</code> prompt that appears, test your Python install by typing
You just started Python! The <code>>>></code> indicates that you are at a new type of prompt -- a Python prompt. The command prompt let's you navigate your computer and run programs, and the Python prompt lets you write and run Python code interactively.
<li>To exit the Python prompt, type
and press Enter. This will take you back to the Windows command prompt (the <code>C:\</code> you saw earlier).</li>
== Required step: Put Python on the PATH ==
You might have noticed that you typed a directory"full namepath" to the Python application above when launching Python (<code>python.exe</code> is the application, but we typed <code>\Python27\python.exe</code>). In this step, you will reconfigureconfigure your computer to put Python on the system PATH so that you can run itPython without typing the ''Python27'' directory name.
=== Get to System Properties ===
'''This will take about 5 extra minutes''', and it is ''essential'' to an easy life using Python down the road.
# Open up "My Computer" by clicking on the Start menu or the Windows logo in the lower-left hand corner, and navigate to "My Computer" (for Windows XP) or "Computer" (For Vista and Windows 7).
(Note: These steps are based on a '''[http://www.youtube.com/watch?v=g9JvseacxPY video that we recommend you watch]'''. They should work equally well on Windows XP, Vista, and 7.)
# ''Right-click'' on the empty space in the window, and choose ''Properties''.
==== GetIf toyou're Systemusing PropertiesXP ====
#* A window should appear whose title islabeled "System Properties" will pop up.
# Open up "My Computer"
# ''Right-click'' on the empty space in the window, and choose ''Properties'
# Click the "Advanced" tab.
#* A window labeled "View basic information about your computer" should appear
# In the new window, click "Advanced system settings"
==== If you're not using XP ====
#* A window should appear whose title is "System Properties".
#* A window labeled "View basic information about your computer" shouldwill appear.
# In the newthis window, click "Advanced system settings"
A window with the title "System Properties" will appear.
=== Edit the Path ===
# Within System Properties, make sure you are in the tab labeled "Advanced".
# Click the button labeled "Environment Variables". A window labeled "Environment Variables" should appear.
#* A window labeled "Environment Variables" will appear.
# In this window, the screen is split between "User variables" and "System variables". Within "System variables", scroll down and find the one labeled '''Path'''. Click the "Edit..." button.
#* A window with the "Variable name" and the "Variable value" should appear. The "Variable value" will already have some text in it; click in the box to unhighlight it (we don't want to accidentally delete that text).
# In the "Variable value" box, scroll to the end. Add thisthe following text, and hit OK. Make sure to include the semicolon at the start! <pre>;c:/\python27/\;c:/\python27/\scripts</pre>
# Hit "OK" to close out the system properties changes.
# Test ityour change:
## Open up a <b>new</b> command prompt: you do this the same way you did above when installing python. This needs to be a new command prompt because the changes you just made didn't take affect in prompts that were already open.
#* Open up a command prompt
#*# Type just "<code>python"</code> into the command prompt to start Python
#*# Notice that you now get a Python interpreter, indicated by the change to a <code>>>></code> prompt.
## Exit the Python prompt by typing <pre>exit()</pre> and hitting enter. Now you're back at the Windows command prompt (<code>C:\</code>).
== Success! ==
You have Python installed and configured.
[[Boston Python workshop 2/Friday setup|&laquo; Back to the Friday setup page]]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.