Jump to content

Python on Windows: Difference between revisions

no edit summary
imported>Jesstess
No edit summary
 
(8 intermediate revisions by 2 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.
 
<ol>
<li>Click http://python.org/ftp/python/2.7.1/python-2.7.1.msi and choose "run" if you have the option to. Otherwise, save it to your Desktop, then minimize windows to see your desktop, and double click on it to start the installer. IfFollow youthe areinstaller running 64-bit Windows or this link doesn't work for any other reason, click Goinstructions to http://python.org/download/ and download the latest version of Python 2.7 (2.7.1 at the time of writing). Unless you know otherwise, get the "Windows Installer" version, and not the "Windows X86-64 Installer" 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>Use the default settings in the installation prompts and click through until the end of the installer.</li>
<li><b>Open* a command prompt (we will be doing this multiple times, so make a note of how to do this!)</b>:<br /><br />If you are usingOn Windows Vista or Windows 7, you should: click on the Start menu (the Windows logo in the lower left of the screen), 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. If you are using Windows XP, click on the Start menu (the Windows logo in the lower left of the screen), click on "Run...", type "cmd" without quotes, and hit enter.<br />You now have a command prompt open in Windows.</li>
* 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.
<li>At the c:\ prompt that appears, test your Python install by typing
<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>
<li>At thethis c<code>C:\</code> prompt that appears, test your Python install by typing
 
<pre>
>>>
</pre>
 
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>
<li>To exit the Python prompt, type
 
<pre>
exit()
</pre>
 
and press Enter. This will take you back to the Windows command prompt (the c<code>C:\</code> you saw earlier).</li>
</ol>
 
== 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.
 
'''This will take about 5 extra minutes''', and it is ''essential'' to an easy life using Python down the road.
 
=== Get to System Properties ===
 
# 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).
# ''Right-click'' on the empty space in the window, and choose ''Properties''.
 
==== If you're using XP ====
* A window labeled "System Properties" will pop up. Click the "Advanced" tab.
 
* A window labeled "System Properties" will pop up. Click the "Advanced" tab.
==== If you're not ====
 
* A window labeled "View basic information about your computer" should appear
*# InClick this window, clickthe "Advanced" system settings"tab.
 
* A window should appear whose title is "System Properties".
==== If you're not using XP ====
* A window labeled "View basic information about your computer" shouldwill appear.
 
# In this window, click "Advanced system settings"
 
* A window shouldwith appear whosethe title is "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" shouldwill 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 If"Variable youvalue" will already have some words listedtext in the "Variable value", thenit; click in the box to unhighlight it. Make(we suredon't thatwant theto currentaccidentally path listed in the box is '''NOT''' highlighted!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 <b>new</b> command prompt orbecause the changes you wonjust made didn't havetake theaffect shorterin pathsprompts availablethat forwere youralready use!open.
#*# 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.