Left: | ||
Right: |
OLD | NEW |
---|---|
1 :tocdepth: 2 | 1 :tocdepth: 2 |
2 | 2 |
3 .. _windows-faq: | 3 .. _windows-faq: |
4 | 4 |
5 ===================== | 5 ===================== |
6 Python on Windows FAQ | 6 Python on Windows FAQ |
7 ===================== | 7 ===================== |
8 | 8 |
9 .. only:: html | 9 .. only:: html |
10 | 10 |
11 .. contents:: | 11 .. contents:: |
12 | 12 |
13 .. XXX need review for Python 3. | 13 .. XXX need review for Python 3. |
14 XXX need review for Windows Vista/Seven? | 14 XXX need review for Windows Vista/Seven? Reviewed Windows 7/8 by kw |
Zach Ware
2014/03/15 05:13:58
Better to just remove the comment. If we have XP
kathweaver
2014/03/18 02:27:06
So when we accomplish a task on a comment, we dele
| |
15 | 15 |
16 .. _running-windows: | |
16 | 17 |
17 How do I run a Python program under Windows? | 18 How do I run a Python program under Windows? |
18 -------------------------------------------- | 19 -------------------------------------------- |
19 | 20 |
21 Starting with Python 3.3, there is launcher for windows. Use is | |
22 discussed at :ref:`launcher`. | |
23 Some users may find that method more efficient than the below method. | |
Zach Ware
2014/03/15 05:13:58
I think adding this paragraph before the next one
kathweaver
2014/03/18 02:27:06
Done.
| |
24 | |
20 This is not necessarily a straightforward question. If you are already familiar | 25 This is not necessarily a straightforward question. If you are already familiar |
21 with running programs from the Windows command line then everything will seem | 26 with running programs from the Windows command line then everything will seem |
22 obvious; otherwise, you might need a little more guidance. | 27 obvious; otherwise, you might need a little more guidance. |
23 | 28 |
24 .. sidebar:: |Python Development on XP|_ | 29 .. sidebar:: |Python Development on XP|_ |
25 :subtitle: `Python Development on XP`_ | 30 :subtitle: `Python Development on XP`_ |
26 | 31 |
27 This series of screencasts aims to get you up and running with Python on | 32 This series of screencasts aims to get you up and running with Python on |
28 Windows XP. The knowledge is distilled into 1.5 hours and will get you up | 33 Windows XP. The knowledge is distilled into 1.5 hours and will get you up |
29 and running with the right Python distribution, coding in your choice of IDE, | 34 and running with the right Python distribution, coding in your choice of IDE, |
30 and debugging and writing solid code with unit-tests. | 35 and debugging and writing solid code with unit-tests. |
31 | 36 |
32 .. |Python Development on XP| image:: python-video-icon.png | 37 .. |Python Development on XP| image:: python-video-icon.png |
33 .. _`Python Development on XP`: | 38 .. _`Python Development on XP`: |
34 http://www.showmedo.com/videos/series?name=pythonOzsvaldPyNewbieSeries | 39 http://www.showmedo.com/videos/series?name=pythonOzsvaldPyNewbieSeries |
35 | 40 |
36 Unless you use some sort of integrated development environment, you will end up | 41 Unless you use some sort of integrated development environment, you will end |
37 *typing* Windows commands into what is variously referred to as a "DOS window" | 42 up *typing* Windows commands into what is variously referred to as a |
38 or "Command prompt window". Usually you can create such a window from your | 43 "DOS window" or "Command prompt window". Usually you can create such a window |
39 Start menu; under Windows 7 the menu selection is :menuselection:`Start --> | 44 from your Start menu; under Windows 7 the menu selection is |
40 Programs --> Accessories --> Command Prompt`. You should be able to recognize | 45 :menuselection:`Start --> Programs --> Accessories --> Command Prompt`; |
41 when you have started such a window because you will see a Windows "command | 46 under Windows 8 right click the Windows Icon or type Command Prompt at |
42 prompt", which usually looks like this:: | 47 the Start Menu. You should be able to recognize when you have started |
48 such a window because you will see a Windows | |
49 "command prompt", which usually looks like this:: | |
Zach Ware
2014/03/15 05:13:58
Sorry, I wasn't entirely clear. Lines that you've
kathweaver
2014/03/18 02:27:06
Done.
| |
43 | 50 |
44 C:\> | 51 C:\> |
45 | 52 |
46 The letter may be different, and there might be other things after it, so you | 53 The letter may be different, and there might be other things after it, so you |
47 might just as easily see something like:: | 54 might just as easily see something like:: |
48 | 55 |
49 D:\YourName\Projects\Python> | 56 D:\YourName\Projects\Python> |
50 | 57 |
51 depending on how your computer has been set up and what else you have recently | 58 depending on how your computer has been set up and what else you have recently |
52 done with it. Once you have started such a window, you are well on the way to | 59 done with it. Once you have started such a window, you are well on the way to |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 will probably tell you where it is installed; the usual location is something | 132 will probably tell you where it is installed; the usual location is something |
126 like ``C:\Python33``. Otherwise you will be reduced to a search of your whole | 133 like ``C:\Python33``. Otherwise you will be reduced to a search of your whole |
127 disk ... use :menuselection:`Tools --> Find` or hit the :guilabel:`Search` | 134 disk ... use :menuselection:`Tools --> Find` or hit the :guilabel:`Search` |
128 button and look for "python.exe". Supposing you discover that Python is | 135 button and look for "python.exe". Supposing you discover that Python is |
129 installed in the ``C:\Python33`` directory (the default at the time of writing), | 136 installed in the ``C:\Python33`` directory (the default at the time of writing), |
130 you should make sure that entering the command :: | 137 you should make sure that entering the command :: |
131 | 138 |
132 c:\Python33\python | 139 c:\Python33\python |
133 | 140 |
134 starts up the interpreter as above (and don't forget you'll need a "CTRL-Z" and | 141 starts up the interpreter as above (and don't forget you'll need a "CTRL-Z" and |
135 an "Enter" to get out of it). Once you have verified the directory, you can | 142 an "Enter" to get out of it). Once you have verified the directory, you can |
Zach Ware
2014/03/15 05:13:58
This comment about needing Ctrl-Z to exit the inte
kathweaver
2014/03/18 02:27:06
Done.
| |
136 add it to the system path to make it easier to start Python by just running | 143 add it to the system path to make it easier to start Python by just running |
137 the ``python`` command. This is currently an option in the installer as of | 144 the ``python`` command. This is currently an option in the installer as of |
138 CPython 3.3. | 145 CPython 3.3. |
139 | 146 |
140 More information about environment variables can be found on the | 147 More information about environment variables and path can be found |
Zach Ware
2014/03/15 05:13:58
The added "and path" doesn't sound right to me, bu
kathweaver
2014/03/18 02:27:06
I've decided to take the directions for environmen
| |
141 :ref:`Using Python on Windows <setting-envvars>` page. | 148 :ref:`below <setting-envvars>` . |
142 | 149 |
143 How do I make Python scripts executable? | 150 How do I make Python scripts executable? |
144 ---------------------------------------- | 151 ---------------------------------------- |
145 | 152 |
146 On Windows, the standard Python installer already associates the .py | 153 On Windows, the standard Python installer already associates the .py |
147 extension with a file type (Python.File) and gives that file type an open | 154 extension with a file type (Python.File) and gives that file type an open |
148 command that runs the interpreter (``D:\Program Files\Python\python.exe "%1" | 155 command that runs the interpreter (``D:\Program Files\Python\python.exe "%1" |
149 %*``). This is enough to make scripts executable from the command prompt as | 156 %*``). This is enough to make scripts executable from the command prompt as |
150 'foo.py'. If you'd rather be able to execute the script by simple typing 'foo' | 157 'foo.py'. If you'd rather be able to execute the script by simple typing 'foo' |
151 with no extension you need to add .py to the PATHEXT environment variable. | 158 with no extension you need to add .py to the PATHEXT environment variable. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 --------------------------------------------------------- | 342 --------------------------------------------------------- |
336 | 343 |
337 Sometimes, when you download the documentation package to a Windows machine | 344 Sometimes, when you download the documentation package to a Windows machine |
338 using a web browser, the file extension of the saved file ends up being .EXE. | 345 using a web browser, the file extension of the saved file ends up being .EXE. |
339 This is a mistake; the extension should be .TGZ. | 346 This is a mistake; the extension should be .TGZ. |
340 | 347 |
341 Simply rename the downloaded file to have the .TGZ extension, and WinZip will be | 348 Simply rename the downloaded file to have the .TGZ extension, and WinZip will be |
342 able to handle it. (If your copy of WinZip doesn't, get a newer one from | 349 able to handle it. (If your copy of WinZip doesn't, get a newer one from |
343 http://www.winzip.com.) | 350 http://www.winzip.com.) |
344 | 351 |
352 .. sectionauthor:: Kathleen Weaver <kathleen@kweaver.org> | |
353 .. moved from using windows | |
354 | |
355 .. _setting-envvars: | |
356 | |
357 How do I Change Environment Settings? | |
Zach Ware
2014/03/15 05:13:58
I still think we're better off linking to an outsi
| |
358 ------------------------------------- | |
359 | |
360 To change environment variables in Windows 7 and 8, you must use the | |
361 built-in dialog. There is an alternative method that works for prior | |
Zach Ware
2014/03/15 05:13:58
This isn't true, `set` and `setx` work just as wel
kathweaver
2014/03/18 02:27:06
Okay, it doesn't work on some of my machines. Howe
| |
362 versions which is described later. | |
363 | |
364 Using the built-in dialog for changing environment variables: | |
365 | |
366 Windows XP: Right-click the icon for your machine | |
367 (usually located on your Desktop and called "My Computer") and choose | |
368 :menuselection:`Properties` there. Then, open the :guilabel:`Advanced` tab | |
369 and click the :guilabel:`Environment Variables` button. | |
370 | |
371 In short, your path is: | |
372 | |
373 :menuselection:`My Computer | |
374 --> Properties | |
375 --> Advanced | |
Zach Ware
2014/03/15 05:13:58
This also works for 7, except "My Computer" is jus
kathweaver
2014/03/18 02:27:06
It does work, but the method for Windows 7 is shor
| |
376 --> Environment Variables` | |
377 | |
378 Windows 7: Right-click the Windows Icon, choose :menuselection:`Contol Panel` . | |
Zach Ware
2014/03/15 05:13:58
What do you mean by "Windows Icon"? Is that the St
kathweaver
2014/03/18 02:27:06
Yes, there is a Windows Icon on Windows 7 that tak
| |
379 Then click :guilabel:`System` and click the :guilabel:`Advanced system settin gs` | |
380 and click the :guilabel:`Environment Variables` button. | |
381 | |
382 In short, your path is: | |
383 | |
384 :menuselection:`Control Panel | |
385 --> System | |
386 --> Advanced system settings | |
387 --> Environment Variables` | |
388 | |
389 Windows 8: Right-click the Windows Icon, choose | |
Zach Ware
2014/03/15 05:13:58
Same question about Windows Icon, though I haven't
kathweaver
2014/03/18 02:27:06
Right click is correct. Clicking takes you to the
| |
390 :menuselection:`System` and click the :guilabel:`Advanced system settings` | |
391 and click the :guilabel:`Environment Variables` button. | |
392 (Windows 8 skips the control panel) | |
393 | |
394 In short, your path is: | |
395 | |
396 :menuselection:`System | |
397 --> Advanced system settings | |
398 --> Environment Variables` | |
399 | |
400 In this dialog, you can add or modify User and System variables. To change | |
401 System variables, you need non-restricted access to your machine | |
402 (i.e. Administrator rights). | |
403 | |
404 Another way of adding variables to your environment in versions prior to | |
405 Windows 7 and 8 is using the :command:`set` | |
Zach Ware
2014/03/15 05:13:58
This is still true for 7 and 8.
kathweaver
2014/03/18 02:27:06
Put it back, I tried it on an "unaffected" machine
| |
406 command:: | |
407 | |
408 set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib | |
409 | |
410 To make this setting permanent, you could add the corresponding command line | |
411 to your :file:`autoexec.bat`. :program:`msconfig` is a graphical interface to | |
412 this file. | |
Zach Ware
2014/03/15 05:13:58
This paragraph should be removed entirely. It is
| |
413 | |
414 Viewing environment variables in all Windows versions 8.1 and below can also | |
Zach Ware
2014/03/15 05:13:58
No need to specify "8.1 and below", since that's a
| |
415 be done more straight-forward: The command prompt will expand strings wrapped | |
Zach Ware
2014/03/15 05:13:58
Even more straightforward than `echo %var%` is to
| |
416 into percent signs automatically:: | |
417 | |
418 echo %PATH% | |
419 | |
420 Consult :command:`set /?` for details on this behaviour. | |
421 | |
422 .. seealso:: | |
423 | |
424 http://support.microsoft.com/kb/100843 | |
425 Environment variables in Windows NT | |
426 | |
427 http://support.microsoft.com/kb/310519 | |
428 How To Manage Environment Variables in Windows XP | |
429 | |
430 http://www.chem.gla.ac.uk/~louis/software/faq/q1.html | |
431 Setting Environment variables, Louis J. Farrugia | |
432 | |
OLD | NEW |