[3.6] bpo-32613: Update window FAQ (GH-5552). (GH-10545) · python/cpython@137da0c (original) (raw)
`@@ -26,8 +26,7 @@ obvious; otherwise, you might need a little more guidance.
`
26
26
`Unless you use some sort of integrated development environment, you will end up
`
27
27
`typing Windows commands into what is variously referred to as a "DOS window"
`
28
28
`or "Command prompt window". Usually you can create such a window from your
`
29
``
`` -
Start menu; under Windows 7 the menu selection is :menuselection:`Start -->
``
30
``
`` -
Programs --> Accessories --> Command Prompt`. You should be able to recognize
``
``
29
search bar by searching for ``cmd``. You should be able to recognize
31
30
`when you have started such a window because you will see a Windows "command
`
32
31
`prompt", which usually looks like this:
`
33
32
``
`@@ -52,19 +51,19 @@ compiles it into bytecodes, and then executes the bytecodes to run your
`
52
51
`program. So, how do you arrange for the interpreter to handle your Python?
`
53
52
``
54
53
`First, you need to make sure that your command window recognises the word
`
55
``
`-
"python" as an instruction to start the interpreter. If you have opened a
`
56
``
command window, you should try entering the command ``python`` and hitting
``
54
`+
"py" as an instruction to start the interpreter. If you have opened a
`
``
55
command window, you should try entering the command ``py`` and hitting
57
56
`return:
`
58
57
``
59
58
`.. code-block:: doscon
`
60
59
``
61
``
`-
C:\Users\YourName> python
`
``
60
`+
C:\Users\YourName> py
`
62
61
``
63
62
`You should then see something like:
`
64
63
``
65
64
`.. code-block:: pycon
`
66
65
``
67
``
`-
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32
`
``
66
`+
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
`
68
67
` Type "help", "copyright", "credits" or "license" for more information.
`
69
68
` >>>
`
70
69
``
`@@ -81,52 +80,33 @@ by entering a few expressions of your choice and seeing the results:
`
81
80
` 'HelloHelloHello'
`
82
81
``
83
82
`Many people use the interactive mode as a convenient yet highly programmable
`
84
``
`` -
calculator. When you want to end your interactive Python session, hold the :kbd:Ctrl
``
85
``
`` -
key down while you enter a :kbd:Z
, then hit the ":kbd:Enter
" key to get back to your
``
86
``
`-
Windows command prompt.
`
``
83
`+
calculator. When you want to end your interactive Python session,
`
``
84
`` +
call the :func:exit
function or hold the :kbd:Ctrl
key down
``
``
85
`` +
while you enter a :kbd:Z
, then hit the ":kbd:Enter
" key to get
``
``
86
`+
back to your Windows command prompt.
`
87
87
``
88
88
`` You may also find that you have a Start-menu entry such as :menuselection:`Start
``
89
``
`` -
--> Programs --> Python 3.3 --> Python (command line)` that results in you
``
``
89
`` +
--> Programs --> Python 3.x --> Python (command line)` that results in you
``
90
90
``` seeing the >>>
prompt in a new window. If so, the window will disappear
`91`
``
`` -
after you enter the :kbd:`Ctrl-Z` character; Windows is running a single "python"
``
``
`91`
`` +
after you call the :func:`exit` function or enter the :kbd:`Ctrl-Z`
``
``
`92`
`+
character; Windows is running a single "python"
`
`92`
`93`
`command in the window, and closes it when you terminate the interpreter.
`
`93`
`94`
``
`94`
``
``` -
If the ``python`` command, instead of displaying the interpreter prompt ``>>>``,
95
``
`-
gives you a message like::
`
``
95
Now that we know the ``py`` command is recognized, you can give your
``
96
`+
Python script to it. You'll have to give either an absolute or a
`
``
97
`+
relative path to the Python script. Let's say your Python script is
`
``
98
located in your desktop and is named ``hello.py``, and your command
``
99
`+
prompt is nicely opened in your home directory so you're seeing something
`
``
100
`+
similar to::
`
96
101
``
97
``
`-
'python' is not recognized as an internal or external command, operable program or batch file.
`
``
102
`+
C:\Users\YourName>
`
98
103
``
99
``
`-
or::
`
``
104
So now you'll ask the ``py`` command to give your script to Python by
``
105
typing ``py`` followed by your script path::
100
106
``
101
``
`-
Bad command or filename
`
102
107
``
103
``
`-
then you need to make sure that your computer knows where to find the Python
`
104
``
`-
interpreter. To do this you will have to modify a setting called PATH, which is
`
105
``
`-
a list of directories where Windows will look for programs.
`
106
``
-
107
``
`-
You should arrange for Python's installation directory to be added to the PATH
`
108
``
`-
of every command window as it starts. If you installed Python fairly recently
`
109
``
`-
then the command ::
`
110
``
-
111
``
`-
dir C:\py*
`
112
``
-
113
``
`-
will probably tell you where it is installed; the usual location is something
`
114
``
like ``C:\Python33``. Otherwise you will be reduced to a search of your whole
115
``
`` -
disk ... use :menuselection:Tools --> Find
or hit the :guilabel:Search
``
116
``
`-
button and look for "python.exe". Supposing you discover that Python is
`
117
``
installed in the ``C:\Python33`` directory (the default at the time of writing),
118
``
`-
you should make sure that entering the command ::
`
119
``
-
120
``
`-
c:\Python33\python
`
121
``
-
122
``
`` -
starts up the interpreter as above (and don't forget you'll need a ":kbd:Ctrl-Z
" and
``
123
``
`` -
an ":kbd:Enter
" to get out of it). Once you have verified the directory, you can
``
124
``
`-
add it to the system path to make it easier to start Python by just running
`
125
``
the ``python`` command. This is currently an option in the installer as of
126
``
`-
CPython 3.3.
`
127
``
-
128
``
`-
More information about environment variables can be found on the
`
129
``
`` -
:ref:Using Python on Windows <setting-envvars>
page.
``
``
108
`+
C:\Users\YourName> py Desktop\hello.py
`
``
109
`+
hello
`
130
110
``
131
111
`How do I make Python scripts executable?
`
132
112
`----------------------------------------
`
`@@ -332,4 +312,3 @@ This is a mistake; the extension should be .TGZ.
`
332
312
`Simply rename the downloaded file to have the .TGZ extension, and WinZip will be
`
333
313
`able to handle it. (If your copy of WinZip doesn't, get a newer one from
`
334
314
`
335
``
-