diff -r e159cb0d955b Doc/faq/windows.rst --- a/Doc/faq/windows.rst Sun Apr 27 10:44:46 2014 -0700 +++ b/Doc/faq/windows.rst Sun Apr 27 17:05:57 2014 -0500 @@ -11,15 +11,19 @@ .. contents:: .. XXX need review for Python 3. - XXX need review for Windows Vista/Seven? +.. _running-windows: How do I run a Python program under Windows? -------------------------------------------- -This is not necessarily a straightforward question. If you are already familiar -with running programs from the Windows command line then everything will seem -obvious; otherwise, you might need a little more guidance. +This is not necessarily a straightforward question. The situation has been +made somewhat simpler since Python 3.3, which introduced the launcher for +Windows. Use is discussed at :ref:`launcher`. + +If you are already familiar with running programs from the Windows command +line then everything will seem obvious; otherwise, you might need a little +more guidance. .. sidebar:: |Python Development on XP|_ :subtitle: `Python Development on XP`_ @@ -34,12 +38,13 @@ http://www.showmedo.com/videos/series?name=pythonOzsvaldPyNewbieSeries Unless you use some sort of integrated development environment, you will end up -*typing* Windows commands into what is variously referred to as a "DOS window" -or "Command prompt window". Usually you can create such a window from your -Start menu; under Windows 7 the menu selection is :menuselection:`Start --> -Programs --> Accessories --> Command Prompt`. You should be able to recognize -when you have started such a window because you will see a Windows "command -prompt", which usually looks like this:: +*typing* Windows commands into what is variously referred to as a "DOS window" +or "Command prompt window". Usually you can create such a window from your +Start menu; under Windows 7 the menu selection is :menuselection:`Start --> +Programs --> Accessories --> Command Prompt`; under Windows 8 right click the +Windows Icon or type Command Prompt at the Start Menu. You should be able to +recognize when you have started such a window because you will see a Windows +"command prompt", which usually looks like this:: C:\> @@ -50,7 +55,8 @@ depending on how your computer has been set up and what else you have recently done with it. Once you have started such a window, you are well on the way to -running Python programs. +running Python programs. In some situations, you may need to use the +administrative command prompt. It is designated as Command Prompt (Admin). You need to realize that your Python scripts have to be processed by another program called the Python *interpreter*. The interpreter reads your script, @@ -66,7 +72,7 @@ You should then see something like:: - Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32 + Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> @@ -81,12 +87,11 @@ HelloHelloHello Many people use the interactive mode as a convenient yet highly programmable -calculator. When you want to end your interactive Python session, hold the Ctrl -key down while you enter a Z, then hit the "Enter" key to get back to your -Windows command prompt. +calculator. When you want to end your interactive Python session, use exit() +or quit() function to get back to your Windows command prompt. You may also find that you have a Start-menu entry such as :menuselection:`Start ---> Programs --> Python 3.3 --> Python (command line)` that results in you +--> Programs --> Python 3.4 --> Python (command line)` that results in you seeing the ``>>>`` prompt in a new window. If so, the window will disappear after you enter the Ctrl-Z character; Windows is running a single "python" command in the window, and closes it when you terminate the interpreter. @@ -123,22 +128,23 @@ dir C:\py* will probably tell you where it is installed; the usual location is something -like ``C:\Python33``. Otherwise you will be reduced to a search of your whole +like ``C:\Python34``. Otherwise you will be reduced to a search of your whole disk ... use :menuselection:`Tools --> Find` or hit the :guilabel:`Search` button and look for "python.exe". Supposing you discover that Python is -installed in the ``C:\Python33`` directory (the default at the time of writing), +installed in the ``C:\Python34`` directory (the default at the time of writing), you should make sure that entering the command :: - c:\Python33\python + c:\Python34\python -starts up the interpreter as above (and don't forget you'll need a "CTRL-Z" and -an "Enter" to get out of it). Once you have verified the directory, you can +starts up the interpreter as above. +Once you have verified the directory, you can add it to the system path to make it easier to start Python by just running the ``python`` command. This is currently an option in the installer as of CPython 3.3. -More information about environment variables can be found on the -:ref:`Using Python on Windows ` page. +If you need further assistance with Environment Settings see: +`How to set the path and environment variables in Windows. `_ +Note: Both Windows 7 and Windows 8 use similar methods to accomplish the task. How do I make Python scripts executable? ---------------------------------------- @@ -204,7 +210,7 @@ be a DLL to handle importing modules that are themselves DLL's. (This is the first key undocumented fact.) Instead, link to :file:`python{NN}.dll`; it is typically installed in ``C:\Windows\System``. *NN* is the Python version, a - number such as "33" for Python 3.3. + number such as "34" for Python 3.4. You can link to Python in two different ways. Load-time linking means linking against :file:`python{NN}.lib`, while run-time linking means linking @@ -268,7 +274,7 @@ _resultobj = Py_None; return _resultobj; - Alas, Py_None is a macro that expands to a reference to a complex data + Alas, Py_None is a macro that expands to a reference to a complex data structure called _Py_NoneStruct inside pythonNN.dll. Again, this code will fail in a mult-compiler environment. Replace such code by: @@ -341,4 +347,3 @@ Simply rename the downloaded file to have the .TGZ extension, and WinZip will be able to handle it. (If your copy of WinZip doesn't, get a newer one from http://www.winzip.com.) -