@@ -24,8 +24,7 @@ obvious; otherwise, you might need a little more guidance.
24
24
Unless you use some sort of integrated development environment, you will end up
25
25
*typing * Windows commands into what is variously referred to as a "DOS window"
26
26
or "Command prompt window". Usually you can create such a window from your
27
- Start menu; under Windows 7 the menu selection is :menuselection: `Start -->
28
- Programs --> Accessories --> Command Prompt `. You should be able to recognize
27
+ search bar by searching for ``cmd ``. You should be able to recognize
29
28
when you have started such a window because you will see a Windows "command
30
29
prompt", which usually looks like this::
31
30
@@ -46,15 +45,15 @@ compiles it into bytecodes, and then executes the bytecodes to run your
46
45
program. So, how do you arrange for the interpreter to handle your Python?
47
46
48
47
First, you need to make sure that your command window recognises the word
49
- "python " as an instruction to start the interpreter. If you have opened a
50
- command window, you should try entering the command ``python `` and hitting
48
+ "py " as an instruction to start the interpreter. If you have opened a
49
+ command window, you should try entering the command ``py `` and hitting
51
50
return::
52
51
53
- C:\Users\YourName> python
52
+ C:\Users\YourName> py
54
53
55
54
You should then see something like::
56
55
57
- Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48 ) [MSC v.1600 32 bit (Intel)] on win32
56
+ Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45 ) [MSC v.1900 32 bit (Intel)] on win32
58
57
Type "help", "copyright", "credits" or "license" for more information.
59
58
>>>
60
59
@@ -69,64 +68,33 @@ by entering a few expressions of your choice and seeing the results::
69
68
'HelloHelloHello'
70
69
71
70
Many people use the interactive mode as a convenient yet highly programmable
72
- calculator. When you want to end your interactive Python session, hold the :kbd: `Ctrl `
73
- key down while you enter a :kbd: `Z `, then hit the ":kbd: `Enter `" key to get back to your
74
- Windows command prompt.
71
+ calculator. When you want to end your interactive Python session,
72
+ call the ``exit() `` function or hold the :kbd: `Ctrl ` key down
73
+ while you enter a :kbd: `Z `, then hit the ":kbd: `Enter `" key to get
74
+ back to your Windows command prompt.
75
75
76
76
You may also find that you have a Start-menu entry such as :menuselection: `Start
77
- --> Programs --> Python 3.3 --> Python (command line) ` that results in you
77
+ --> Programs --> Python 3.6 --> Python (command line) ` that results in you
78
78
seeing the ``>>> `` prompt in a new window. If so, the window will disappear
79
- after you enter the :kbd: `Ctrl - Z ` character; Windows is running a single "python"
79
+ after you call the ``exit() `` function or enter the :kbd: `Ctrl - Z `
80
+ character; Windows is running a single "python"
80
81
command in the window, and closes it when you terminate the interpreter.
81
82
82
- If the ``python `` command, instead of displaying the interpreter prompt ``>>> ``,
83
- gives you a message like::
83
+ Now that we know the ``py `` command is recognized, you can give your
84
+ Python script to it. You'll have to give either an absolute or a
85
+ relative path to the Python script. Let's say your Python script is
86
+ located in your desktop and is named ``hello.py ``, and your command
87
+ prompt is nicely opened in your home directory so you're seeing something
88
+ similar to::
84
89
85
- 'python' is not recognized as an internal or external command, operable program or batch file.
90
+ C:\Users\YourName>
86
91
87
- .. sidebar :: |Adding Python to DOS Path|_
88
- :subtitle: ` Adding Python to DOS Path `_
92
+ So now you'll ask the `` py `` command to give your script to Python by
93
+ typing `` py `` followed by your script path::
89
94
90
- Python is not added to the DOS path by default. This screencast will walk
91
- you through the steps to add the correct entry to the `System Path `, allowing
92
- Python to be executed from the command-line by all users.
95
+ C:\Users\YourName> py Desktop\hello.py
96
+ hello
93
97
94
- .. |Adding Python to DOS Path | image :: python-video-icon.png
95
- .. _`Adding Python to DOS Path` :
96
- http://showmedo.com/videotutorials/video?name=960000&fromSeriesID=96
97
-
98
-
99
- or::
100
-
101
- Bad command or filename
102
-
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.
130
98
131
99
How do I make Python scripts executable?
132
100
----------------------------------------
@@ -330,4 +298,3 @@ This is a mistake; the extension should be .TGZ.
330
298
Simply rename the downloaded file to have the .TGZ extension, and WinZip will be
331
299
able to handle it. (If your copy of WinZip doesn't, get a newer one from
332
300
https://www.winzip.com.)
333
-
0 commit comments