Editing Python on Windows

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
 
== Download and install Python ==
 
== Download and install Python ==
 
If you believe you already have Python installed, please let a staff member know before completing these steps.
 
  
 
<ol>
 
<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. Follow the installer instructions to completion.</li>
+
<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. If you are running 64-bit Windows or this link doesn't work for any other reason, click Go 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" version.</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>
* On Windows Vista or Windows 7: 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.
+
<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 using Windows Vista or Windows 7, you should click on the Start menu (the Windows logo in the lower left of the screen), type "cmd" 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 this <code>C:\</code> prompt that appears, test your Python install by typing
 
  
 
<pre>
 
<pre>
Line 23: Line 17:
 
>>>
 
>>>
 
</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>
 
<li>To exit the Python prompt, type
 
<li>To exit the Python prompt, type
  
<pre>
+
exit()
exit()
 
</pre>
 
  
and press Enter. This will take you back to the Windows command prompt (the <code>C:\</code> you saw earlier).</li>
+
and press Enter. This will take you back to the Windows command prompt (the c:\ you saw earlier).</li>
 
</ol>
 
</ol>
  
== Put Python on the PATH ==
+
== Required step: Put Python on the PATH ==
  
You might have noticed that you typed a "full path" 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 configure your computer so that you can run Python without typing the ''Python27'' directory name.
+
You might have noticed that you typed a directory name above when launching Python. In this step, you will reconfigure your computer to put Python on the system PATH so that you can run it 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 ===
 
=== 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).
 
# 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''.
+
# ''Right-click'' on the empty space in the window, and choose ''Properties''
  
 
==== If you're using XP ====
 
==== 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.
+
==== If you're not ====
 
+
* A window labeled "View basic information about your computer" should appear
# Click the "Advanced" tab.
+
* In this window, click "Advanced system settings"
 
+
* A window should appear whose title is "System Properties".
==== If you're not using XP ====
 
A window labeled "View basic information about your computer" will appear.
 
 
 
# In this window, click "Advanced system settings"
 
 
 
A window with the title "System Properties" will appear.
 
  
 
=== Edit the Path ===
 
=== Edit the Path ===
Line 62: Line 48:
 
# Within System Properties, make sure you are in the tab labeled "Advanced".
 
# Within System Properties, make sure you are in the tab labeled "Advanced".
 
# Click the button labeled "Environment Variables".
 
# Click the button labeled "Environment Variables".
#* A window labeled "Environment Variables" will appear.
+
#* A window labeled "Environment Variables" should 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.
 
# 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).
+
#* A window with the "Variable name" and the "Variable value" should appear. If you have some words listed in the "Variable value", then click in the box to unhighlight it. Make sure that the current path listed in the box is '''NOT''' highlighted! 
# In the "Variable value" box, scroll to the end. Add the following text, and hit OK. Make sure to include the semicolon at the start! <pre>;c:\python27\;c:\python27\scripts</pre>
+
# In the "Variable value", scroll to the end. Add this 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.
 
# Hit "OK" to close out the system properties changes.
# Test your change:
+
# Test it:
## 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 <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 or you won't have the shorter paths available for your use!
## Type <code>python</code> into the command prompt to start Python
+
#* Type just "python" into the command prompt
## Notice that you now get a Python interpreter, indicated by the change to a <code>>>></code> prompt.
+
#* Notice that you now get a Python interpreter.
## 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! ==
+
== Success ==
  
You have Python installed and configured.
+
You have Python installed.
  
 
[[Boston Python workshop 2/Friday setup|&laquo; Back to the Friday setup page]]
 
[[Boston Python workshop 2/Friday setup|&laquo; Back to the Friday setup page]]

Please note that all contributions to OpenHatch wiki are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) (see OpenHatch wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)