I have installed the latest Python for Win10 from Releases for Windows.
Just typing py
in the Command Prompt Window
starts Python.
Microsoft Windows [Version 10.0.15048]
(c) 2017 Microsoft Corporation. All rights reserved.
C:Userssg7>py
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>`enter code here`
Testing:
>>> print("hello!")
hello!
>>>
Please be aware that in my case Python was installed in C:Userssg7AppDataLocalProgramsPythonPython36>
directory
C:Userssg7AppDataLocalProgramsPythonPython36>dir
Volume in drive C is Windows7_OS
Volume Serial Number is 1226-12D1
Directory of C:Userssg7AppDataLocalProgramsPythonPython36
08/05/2018 07:38 AM <DIR> .
08/05/2018 07:38 AM <DIR> ..
12/18/2017 09:12 AM <DIR> DLLs
12/18/2017 09:12 AM <DIR> Doc
12/18/2017 09:12 AM <DIR> include
12/18/2017 09:12 AM <DIR> Lib
12/18/2017 09:12 AM <DIR> libs
10/03/2017 07:17 PM 30,334 LICENSE.txt
10/03/2017 07:17 PM 362,094 NEWS.txt
10/03/2017 07:15 PM 100,504 python.exe
10/03/2017 07:12 PM 58,520 python3.dll
10/03/2017 07:12 PM 3,610,776 python36.dll
10/03/2017 07:15 PM 98,968 pythonw.exe
08/05/2018 07:38 AM 196,096 Removescons.exe
08/05/2018 07:38 AM 26,563 scons-wininst.log
08/05/2018 07:38 AM <DIR> Scripts
12/18/2017 09:12 AM <DIR> tcl
12/18/2017 09:12 AM <DIR> Tools
06/09/2016 11:53 PM 87,888 vcruntime140.dll
9 File(s) 4,571,743 bytes
10 Dir(s) 20,228,898,816 bytes free
When I am at C:Userssg7>
directory level python
can be invoked by typing
AppDataLocalProgramsPythonPython36python
C:Userssamg>AppDataLocalProgramsPythonPython36python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Newer Python 3.7 will be installed at:
C:UsersYourUserNameHereAppDataLocalProgramsPythonPython37
If you wish you can add to your path environment variable:
%USERPROFILE%AppDataLocalProgramsPythonPython36
Whenever I run
python
incmd
I get this error'python' is not recognized as an internal or external command, operable program or batch file
.
You need to add python.exe
to your Windows path variable(s). You can do this when installing Python with the official installer from python.org by selecting a custom installation and marking the correct option to add Python to your environment variables.
If you need to add the path to Python to your Windows path variable(s) manually (ex. because Python is already installed), look for the Windows Search and type env
into it. Click the first link indicating you wish to edit your environment variables.
-
If you are on Windows 7, add e.g.
;C:pathtopython
to the end of yourPath
variable underSystem variables
, wherepython
is your Python installation folder (only usePATH
under your user variables if you want Python to be accessible by that user alone). If you click the wrong link in Windows Search, you may need to click theEnvironment Variables...
button to get to the settings described. -
On Windows 10, just add
C:pathtopython
to the end of the list (in a new field). -
Do not add
python.exe
to your path entry (i.e.C:pathtopythonpython.exe
is wrong).
Python will work in my Jupyter Notebook, but if I need to
pip
install something I am unable to do so.
Adding Python to you environment variables through the official installer (above) should solve this. If not, you will need to perform the same (rough) steps above but add C:pathtopythonScripts
to your path (Scripts
is the folder where pip.exe
lives).
In either case, reboot your PC before attempting to access python
/pip
from the command line.
I’m trying to -learn to write and- run Python scripts on my Windows 7 64 bit machine. I installed Python in C:/Python34, and I added this to my Windows’ PATH variable :
C:Python34; C:Python34python.exe
(the second one is probably meaningless but I tried) and still I get this error in Windows command line :
C:Usersme>python test.py
'python' is not recognized as an internal or external command,
operable program or batch file.
So how do I truly install Python on my Windows x64 machine ?
asked Jun 12, 2014 at 14:22
2
This might be trivial, but have you tried closing your command line window and opening a new one? This is supposed to reload all the environment variables.
Try typing
echo %PATH%
into the command prompt and see if you can find your Python directory there.
Also, the second part of your addition to the PATH environment variable is indeed unnecessary.
answered Jun 12, 2014 at 14:28
yossimyossim
2761 silver badge5 bronze badges
7
I had the same problem: python not being recognized, with python in the path which was was not truncated.
Following the comment of eryksun in yossim’s answer:
Also, if you installed for all users you should have %SystemRoot%py.exe, which >is typically C:Windowspy.exe. So without setting Python’s directory in PATH >you can simply run py to start Python; if 2.x is installed use py -3 since >Python 2 is the default. – eryksun
I tried to use py instead of python and it worked.
Meaning:
python setup.py build -> does NOT work.
py setup.py build -> does work.
Hope it helps
answered Sep 21, 2017 at 14:17
senis000senis000
2312 silver badges6 bronze badges
3
I was also having the same problem.
Turns out the path I added included ‘..python.exe’ at the end, which as turns out was not required. I only needed to add the directory in which ‘python.exe’ is in (which in my case is the Anaconda’s distribution directory in Users folder), similar to what we do when installing JDK in our system’s PATH variable.
Hope it helps!
answered Jul 29, 2018 at 4:54
Arnab RoyArnab Roy
1751 silver badge7 bronze badges
It wasn’t working for me even after adding the path. What finally did the trick, was changing the order of listed paths in the PATH
variable. I moved %USERPROFILE%AppDataLocalMicrosoftWindowsApps
down vs. having it the first path listed there.
vvvvv
21k17 gold badges46 silver badges66 bronze badges
answered Apr 3, 2022 at 6:50
uditgtuditgt
1111 silver badge1 bronze badge
2
Environment PATH Length Limitation is 1024 characters
If restarting your cmd window does not work you might have reached the character limit for PATH, which is a surprisingly short 1024 characters.
Note that the user interface will happily allows you to define a PATH that is way longer than 1024, and will just truncate anything longer than this. Use
echo %PATH%
in your cmd window to see if the PATH being truncated.
Solution
Unfortunately, there is no good way to fix this besides removing something else from your PATH.
NOTE: Your PATH = SYSTEM_PATH + USER_PATH, so you need to make sure the combined is < 1024.
answered Jun 12, 2014 at 15:00
bcorsobcorso
44.8k9 gold badges62 silver badges75 bronze badges
1
Also, make sure to leave no spaces after the semi-colon.
For example, this didn’t work for me:
C:Windowssystem32; C:Python27; C:Python27Scripts;
But, this did:
C:Windowssystem32;C:Python27;C:Python27Scripts;
answered Mar 29, 2018 at 17:21
nihal111nihal111
3483 silver badges9 bronze badges
2
I did everything:
- Added Python to PATH
- Uninstall all the Pythons — Both from downloaded python.org and Microsoft Store and reinstall from python.org
- Change the order of PATH
- Deleted
%USERPROFILE%AppDataLocalMicrosoftWindowsApps
from PATH
But nothing worked. What worked for me was:
Settings > Application > App execution aliases. Then disable all the Pyhtons from here and it worked!
answered Dec 2, 2022 at 14:05
tatolinetatoline
2254 silver badges9 bronze badges
I’m late to the game here, but I’d like to share my solution for future users. The previous answers were on the right track, but if you do not open the CMD as an administrator, then you will be thrown that same error. I know this seems trivial and obvious, but after spending the past 8 hours programming before attempting to install Django for the first time, you might be surprised at the stupid mistakes you might make.
answered Jan 30, 2015 at 17:40
I have faced same problem even though my path contains 400 characters.
Try to update the path from the command line(Run as administrator)
Command to update path: setx path «%path%;c:examplePath»
After this command I could see that paths that I configured earlier in environment variables got updated and working.
To check the configured paths: echo %PATH%
answered Jul 4, 2019 at 6:23
1
I was facing similar porblem. What helped me is where command.
C:WINDOWSsystem32>where python
C:UsersxxxxxxxAppDataLocalMicrosoftWindowsAppspython.exe
C:Program Files (x86)Microsoft Visual
StudioSharedPython39_86python.exe
On updating PATH variable to point to only one desired directory (basically I removed %USERPROFILE%AppDataLocalMicrosoftWindowsApps from PATH) fixed my problem.
answered Mar 31, 2022 at 8:00
I had the same issue with Python 2.7 on Windows 10 until I changed the file path in Enviroment Variables to the folder path, ie C:Python27python.exe
didn’t work but C:Python27
did work.
answered Oct 31, 2018 at 12:33
Nick WNick W
8311 gold badge14 silver badges28 bronze badges
For me, installing the ‘Windows x86-64 executable installer’ from the official python portal did the trick.
Python interpreter was not initially recognized, while i had installed 32 bit python.
Uninstalled python 32 bit and installed 64 bit.
So, if you are on a x-64 processor, install 64bit python.
answered Mar 11, 2019 at 15:42
I tried it multiple times with the default installer option, the first one, (Python 3.7.3) with both ‘add to environment variable’ and ‘all users’ checked, though the latter was greyed out and couldn’t be unchecked.
It failed to work for other users except for the user I installed it under until I uninstalled it and chose «Custom Install». It then clearly showed the install path being in the C:Program FilesPython37 directory when it was failing to install it there the other way even though the ‘All Users’ option was checked.
answered May 16, 2019 at 1:08
Same thing was happening with me when i was trying to open the python immediately with CMD.
Then I kept my in sleep mode and started CMD using these Key Windows_key+R, typed cmd and OK. Then the package of python worked perfectly.
Matthew
1,8673 gold badges17 silver badges25 bronze badges
answered Jun 20, 2019 at 9:15
- Uninstall python and pyqt
- Then go to pyqt setup and open installation but don’t install. You will see a message box saying something like
pyqt version built with python version 32bit/64bit
. - Then see python version bit and download that version from python.org from all release menu.
- Then first install python and then install pyqt. It will work like butter.
answered Nov 30, 2019 at 23:41
I spent sometime checking and rechecking the path and restarting to no avail.
The only thing that worked for me was to rename the executable C:Python34python.exe to C:Python34python34.exe. This way, calling typing python34 at the command line now works.
On windows it seems that when calling ‘python’, the system finds C:Python27 in the path before it finds C:Python34
I’m not sure if this is the right way to do this, seems like a hack, but it seems to work OK.
answered Jan 8, 2015 at 18:41
1
I’m trying to -learn to write and- run Python scripts on my Windows 7 64 bit machine. I installed Python in C:/Python34, and I added this to my Windows’ PATH variable :
C:Python34; C:Python34python.exe
(the second one is probably meaningless but I tried) and still I get this error in Windows command line :
C:Usersme>python test.py
'python' is not recognized as an internal or external command,
operable program or batch file.
So how do I truly install Python on my Windows x64 machine ?
asked Jun 12, 2014 at 14:22
2
This might be trivial, but have you tried closing your command line window and opening a new one? This is supposed to reload all the environment variables.
Try typing
echo %PATH%
into the command prompt and see if you can find your Python directory there.
Also, the second part of your addition to the PATH environment variable is indeed unnecessary.
answered Jun 12, 2014 at 14:28
yossimyossim
2761 silver badge5 bronze badges
7
I had the same problem: python not being recognized, with python in the path which was was not truncated.
Following the comment of eryksun in yossim’s answer:
Also, if you installed for all users you should have %SystemRoot%py.exe, which >is typically C:Windowspy.exe. So without setting Python’s directory in PATH >you can simply run py to start Python; if 2.x is installed use py -3 since >Python 2 is the default. – eryksun
I tried to use py instead of python and it worked.
Meaning:
python setup.py build -> does NOT work.
py setup.py build -> does work.
Hope it helps
answered Sep 21, 2017 at 14:17
senis000senis000
2312 silver badges6 bronze badges
3
I was also having the same problem.
Turns out the path I added included ‘..python.exe’ at the end, which as turns out was not required. I only needed to add the directory in which ‘python.exe’ is in (which in my case is the Anaconda’s distribution directory in Users folder), similar to what we do when installing JDK in our system’s PATH variable.
Hope it helps!
answered Jul 29, 2018 at 4:54
Arnab RoyArnab Roy
1751 silver badge7 bronze badges
It wasn’t working for me even after adding the path. What finally did the trick, was changing the order of listed paths in the PATH
variable. I moved %USERPROFILE%AppDataLocalMicrosoftWindowsApps
down vs. having it the first path listed there.
vvvvv
21k17 gold badges46 silver badges66 bronze badges
answered Apr 3, 2022 at 6:50
uditgtuditgt
1111 silver badge1 bronze badge
2
Environment PATH Length Limitation is 1024 characters
If restarting your cmd window does not work you might have reached the character limit for PATH, which is a surprisingly short 1024 characters.
Note that the user interface will happily allows you to define a PATH that is way longer than 1024, and will just truncate anything longer than this. Use
echo %PATH%
in your cmd window to see if the PATH being truncated.
Solution
Unfortunately, there is no good way to fix this besides removing something else from your PATH.
NOTE: Your PATH = SYSTEM_PATH + USER_PATH, so you need to make sure the combined is < 1024.
answered Jun 12, 2014 at 15:00
bcorsobcorso
44.8k9 gold badges62 silver badges75 bronze badges
1
Also, make sure to leave no spaces after the semi-colon.
For example, this didn’t work for me:
C:Windowssystem32; C:Python27; C:Python27Scripts;
But, this did:
C:Windowssystem32;C:Python27;C:Python27Scripts;
answered Mar 29, 2018 at 17:21
nihal111nihal111
3483 silver badges9 bronze badges
2
I did everything:
- Added Python to PATH
- Uninstall all the Pythons — Both from downloaded python.org and Microsoft Store and reinstall from python.org
- Change the order of PATH
- Deleted
%USERPROFILE%AppDataLocalMicrosoftWindowsApps
from PATH
But nothing worked. What worked for me was:
Settings > Application > App execution aliases. Then disable all the Pyhtons from here and it worked!
answered Dec 2, 2022 at 14:05
tatolinetatoline
2254 silver badges9 bronze badges
I’m late to the game here, but I’d like to share my solution for future users. The previous answers were on the right track, but if you do not open the CMD as an administrator, then you will be thrown that same error. I know this seems trivial and obvious, but after spending the past 8 hours programming before attempting to install Django for the first time, you might be surprised at the stupid mistakes you might make.
answered Jan 30, 2015 at 17:40
I have faced same problem even though my path contains 400 characters.
Try to update the path from the command line(Run as administrator)
Command to update path: setx path «%path%;c:examplePath»
After this command I could see that paths that I configured earlier in environment variables got updated and working.
To check the configured paths: echo %PATH%
answered Jul 4, 2019 at 6:23
1
I was facing similar porblem. What helped me is where command.
C:WINDOWSsystem32>where python
C:UsersxxxxxxxAppDataLocalMicrosoftWindowsAppspython.exe
C:Program Files (x86)Microsoft Visual
StudioSharedPython39_86python.exe
On updating PATH variable to point to only one desired directory (basically I removed %USERPROFILE%AppDataLocalMicrosoftWindowsApps from PATH) fixed my problem.
answered Mar 31, 2022 at 8:00
I had the same issue with Python 2.7 on Windows 10 until I changed the file path in Enviroment Variables to the folder path, ie C:Python27python.exe
didn’t work but C:Python27
did work.
answered Oct 31, 2018 at 12:33
Nick WNick W
8311 gold badge14 silver badges28 bronze badges
For me, installing the ‘Windows x86-64 executable installer’ from the official python portal did the trick.
Python interpreter was not initially recognized, while i had installed 32 bit python.
Uninstalled python 32 bit and installed 64 bit.
So, if you are on a x-64 processor, install 64bit python.
answered Mar 11, 2019 at 15:42
I tried it multiple times with the default installer option, the first one, (Python 3.7.3) with both ‘add to environment variable’ and ‘all users’ checked, though the latter was greyed out and couldn’t be unchecked.
It failed to work for other users except for the user I installed it under until I uninstalled it and chose «Custom Install». It then clearly showed the install path being in the C:Program FilesPython37 directory when it was failing to install it there the other way even though the ‘All Users’ option was checked.
answered May 16, 2019 at 1:08
Same thing was happening with me when i was trying to open the python immediately with CMD.
Then I kept my in sleep mode and started CMD using these Key Windows_key+R, typed cmd and OK. Then the package of python worked perfectly.
Matthew
1,8673 gold badges17 silver badges25 bronze badges
answered Jun 20, 2019 at 9:15
- Uninstall python and pyqt
- Then go to pyqt setup and open installation but don’t install. You will see a message box saying something like
pyqt version built with python version 32bit/64bit
. - Then see python version bit and download that version from python.org from all release menu.
- Then first install python and then install pyqt. It will work like butter.
answered Nov 30, 2019 at 23:41
I spent sometime checking and rechecking the path and restarting to no avail.
The only thing that worked for me was to rename the executable C:Python34python.exe to C:Python34python34.exe. This way, calling typing python34 at the command line now works.
On windows it seems that when calling ‘python’, the system finds C:Python27 in the path before it finds C:Python34
I’m not sure if this is the right way to do this, seems like a hack, but it seems to work OK.
answered Jan 8, 2015 at 18:41
1
Command prompt
I tried to run this python code:
#two brown number are an ordered pair in the form (m; n) such that n!+1=m^2
from math import factorial as fact
m=2
n=2
for i in range(10**2): # range of values to check
# checks current values and changes them according to results
if (fact(n)+1)==m**2:
print(m,n)
m+=1
n+=1
elif (fact(n)+1)<m**2:
n+=1
elif (fact(n)+1)>m**2:
m+=1
from the command prompt but it showed me the message on the image above, even though I already installed python 3.9 from the official website.
The python stuff I installed
Anyone knows how to fix this or do I have to reinstall python from the Microsoft Store?
asked Aug 26, 2021 at 10:53
5
Rename your file containing the code.
There must not be spaces and then use the command:
python3 filename.py
answered Aug 26, 2021 at 11:03
PieroPiero
3442 gold badges6 silver badges19 bronze badges
To call files with spaces use the quotation marks around them.
python ".brown numbers.py"
Generally, it is better to avoid spaces in files names, but sometimes it is unavoidable. In such situations you must explicitly tell Python what is the full file name.
To check if Python is installed correctly run:
python --version
answered Aug 26, 2021 at 11:11
Command prompt
I tried to run this python code:
#two brown number are an ordered pair in the form (m; n) such that n!+1=m^2
from math import factorial as fact
m=2
n=2
for i in range(10**2): # range of values to check
# checks current values and changes them according to results
if (fact(n)+1)==m**2:
print(m,n)
m+=1
n+=1
elif (fact(n)+1)<m**2:
n+=1
elif (fact(n)+1)>m**2:
m+=1
from the command prompt but it showed me the message on the image above, even though I already installed python 3.9 from the official website.
The python stuff I installed
Anyone knows how to fix this or do I have to reinstall python from the Microsoft Store?
asked Aug 26, 2021 at 10:53
5
Rename your file containing the code.
There must not be spaces and then use the command:
python3 filename.py
answered Aug 26, 2021 at 11:03
PieroPiero
3442 gold badges6 silver badges19 bronze badges
To call files with spaces use the quotation marks around them.
python ".brown numbers.py"
Generally, it is better to avoid spaces in files names, but sometimes it is unavoidable. In such situations you must explicitly tell Python what is the full file name.
To check if Python is installed correctly run:
python --version
answered Aug 26, 2021 at 11:11
Сегодня поговорим об установке Python и о первых проблемах с которыми могут столкнуться начинающие программисты. После установки Python все советую проверит правильность его установки введя в командной строке Python, после этого вы должны увидеть установленную версию питона. Так же вы сможете вводим простенькие команды и выполнять их через командную строку например, введя print(«привет»), код должен выполниться и отобразить просто «Привет».
Для установки различных модулей используется PIP, например, для установки requests в командной строке нужно ввести pip install requests. Вообще большинство пользователей после установки питона и введя в командной строке «PIP» или «Python» получает сообщение об ошибке «не является внутренней или внешней командой, исполняемой программой или пакетным файлом».
Решение данный проблемы очень простое, в интернете очень много ответов, но все они очень краткие, сжатые, без скриншотов. Разобраться новичку будет достаточно сложно. Большинство ответов имеют вот такой вид
«Вам нужно установить путь к pip в переменные окружения»
Думаю новичку это абсолютно ни о чем не говорит, он еще больше запутается. Поэтому я решил подробно описать решение данной проблемы.
Простое решение проблемы в Windows 10
И так при вводе в командной строке PIP вы видите сообщение.
«PIP» не является внутренней или внешней командой, исполняемой программой или пакетным файлом
Тоже самое и с Python
«Python» не является внутренней или внешней командой, исполняемой программой или пакетным файлом
Вам нужно добавить значения в переменную Path, рассказывать что это не буду, просто открываем свойства компьютера и выбираем «Дополнительные параметры системы».
Далее в свойствах системы переходим во вкладку «Дополнительно» и снижу нажимаем «Переменные среды».
В открывшемся окне в верхней части отмечаем переменную «Path» и нажимаем изменить.
В поле «Значение переменной» дописываем путь до папки в которой у вас установлен Питон, в моем случае это С:Python, так же нужно указать путь до папки где лежит файл pip.exe у меня это С:PythonScripts. Дописываем через ; вот так.
С:PythonScripts;С:Python;
Сохраняем.
Рекомендую изменять стандартный путь установки Питона на С:Python.
Теперь проверяем результат запускаем командную строку и пишем сначала «PIP».
Потом пробуем написать «Python», после шеврона (>>>) можно уже написать какой нибудь код например, print(«Привет!»).
Если выше описанное для вас сложно, то можно переустановить сам Питон, отметив в главном окне пункт «Add Python 3.9 to PATH».
В процессе установки все пути будут прописаны автоматически. Вот так можно избавиться от ошибки «не является внутренней или внешней командой, исполняемой программой или пакетным файлом», которая появляется в командной строке при вводе «PIP» или «Python».
Уведомления
- Начало
- » Python для новичков
- » Не запускается python из cmd
#1 Фев. 26, 2013 21:35:09
Не запускается python из cmd
Здравствуйте. Установил python3.3 на Windows7-64bit. Прописал Path в системные переменные: Имя переменной “python”, значение переменной “C:Python33;C:Python33Libsite-packages;C:Python33Scripts;”. Все равно не запускается, пишет “”python“ не является внутренней или внешней
командой, исполняемой программой или пакетным файлом.” Из директории в которой находится python запускается.
Что мне сделать чтобы он запускался и из других папок? Гугл не помог…
Офлайн
- Пожаловаться
#2 Фев. 26, 2013 21:57:40
Не запускается python из cmd
Вообще-то переменная окружения и должна называться PATH. Она уже есть, нужно к ней дописать путь к папке, где лежит python.exe
Отредактировано cutwater (Фев. 26, 2013 21:58:40)
Офлайн
- Пожаловаться
#3 Фев. 27, 2013 01:55:45
Не запускается python из cmd
там же установщик уже имеет опцию добавления в PATH
Stroy71
Все равно не запускается
надо перезайти в систему
Офлайн
- Пожаловаться
#4 Фев. 27, 2013 09:22:19
Не запускается python из cmd
cutwater
Вообще-то переменная окружения и должна называться PATH. Она уже есть, нужно к ней дописать путь к папке, где лежит python.exe
Спасибо большое! Все получилось.
Офлайн
- Пожаловаться
#5 Фев. 27, 2013 14:28:13
Не запускается python из cmd
py.user.next
надо перезайти в систему
Ну зачем так радикально. Могло быть достаточно заново открыть консоль.
Офлайн
- Пожаловаться
#6 Фев. 27, 2013 21:51:33
Не запускается python из cmd
Может это какой-то неизвестный баг, но на одном западном форуме я видел сообщение о проблеме, подобной моей. К сожалению там ее решить не смогли. Всё дело в том, что я неправильно прописал переменную окружения. Вернее, не нужно было создавать новую, а воспользоваться уже имеющей переменной PATH.
Кстати в Windows XP подобной проблемы не возникло. И прописывать ничего не пришлось.
Отредактировано Stroy71 (Фев. 28, 2013 10:35:28)
Офлайн
- Пожаловаться
#7 Фев. 27, 2013 22:58:17
Не запускается python из cmd
Если прописать в %PATH%, изменения будут доступны только в текущей консоли. Чтобы оно было доступно везде, надо нажать Win+Break -> Дополнительно -> Переменные окружения, дописать свой путь в PATH, ок и открыть новую консоль.
Офлайн
- Пожаловаться
#8 Фев. 28, 2013 01:06:25
Не запускается python из cmd
krishnarama
Ну зачем так радикально. Могло быть достаточно заново открыть консоль.
этого может не хватить, чтобы все консоли открывались с новым PATH (возможно, они наследуются от основной консоли, которая загружается при входе)
Офлайн
- Пожаловаться
#9 Фев. 28, 2013 13:04:36
Не запускается python из cmd
py.user.next
основной консоли, которая загружается при входе)
Мы про windows? И все это легко проверяется экспериментом, зачем гадать.
Офлайн
- Пожаловаться
#10 Март 1, 2013 01:46:58
Не запускается python из cmd
krishnarama
И все это легко проверяется экспериментом
да, согласен
раньше нужно было перезайти, но тогда я через реестр менял переменные среды, потому что не знал про специальное место в системе, где можно устанавливать их (на XP дело было)
Офлайн
- Пожаловаться
- Начало
- » Python для новичков
- » Не запускается python из cmd
Загрузить PDF
Загрузить PDF
Из этой статьи вы узнаете, как открыть файл Python при помощи встроенной Командной строки на компьютере под управлением Windows. В большинстве случаев это можно сделать без каких-либо проблем — главное, чтобы на вашем компьютере был установлен Python. Если вы установили старую версию Python или использовали пользовательские настройки в ходе установки, из-за которых команда «python» не была добавлена в список переменных «Path» на компьютере, вам придется добавить Python в список переменных «Path», чтобы иметь возможность запускать файл Python через командную строку.
-
1
Перейдите к папке с файлом Python. Найдите файл Python, который хотите открыть в Командной строке.
- Если вам уже известен путь к файлу Python, который вы хотите открыть, перейдите к разделу об открытии файла в Командной строке..
-
2
Выберите файл Python. Нажмите один раз на файл Python, путь к которому вы хотите узнать.
-
3
Щелкните правой кнопкой мыши по файлу Python. Появится выпадающее меню.
-
4
Выберите Свойства из выпадающего меню. Откроется окно свойств.
-
5
Обратите внимание на значение в строке «Расположение». Адрес папки (или «путь») справа от пункта «Расположение» — это именно то, что вам нужно ввести в Командную строку, чтобы перейти к каталогу, в котором хранится файл Python.
- Чтобы скопировать расположение, его необходимо выделить (зажмите и перетащите указатель мыши по значению в строке «Расположение»), а затем нажать Ctrl+C.
Реклама
-
1
Откройте меню «Пуск»
. Щелкните по логотипу Windows в нижнем левом углу экрана. Появится меню «Пуск».
-
2
Найдите Командную строку, введя cmd.
-
3
Нажмите на
Командная строка в верхней части меню «Пуск», чтобы открыть Командную строку.
-
4
Перейдите к расположению файла Python. Введите cd и нажмите пробел, после чего введите адрес «Расположение» файла Python и нажмите ↵ Enter.
- К примеру, чтобы открыть файл Python в папке с именем «Файлы» на рабочем столе, вам нужно ввести cd desktop/Файлы.
- Если вы скопировали путь к файлу, введите cd и нажмите пробел, после чего нажмите Ctrl+V, чтобы вставить путь.
-
5
Введите команду «python» и имя файла. Введите python файл.py, где файл — это имя файла Python.
- К примеру, если файл Python называется «script», введите python script.py.
- Если в имени файла Python есть один или несколько пробелов, окружите имя и расширение файла кавычками (например, python "my script.py").
-
6
Нажмите ↵ Enter, чтобы запустить команду и открыть файл Python через установленную на компьютере программу Python.
- Если после нажатия клавиши «Enter» вы столкнетесь с ошибкой, сообщающей, что
'python' не распознается как внутренняя или внешняя команда
, вам нужно будет добавить Python в список «PATH», прежде чем вернуться к этой части.
Реклама
- Если после нажатия клавиши «Enter» вы столкнетесь с ошибкой, сообщающей, что
-
1
Включите отображение скрытых папок. Поскольку одна из папок, в которой находится установочный каталог Python, скорее всего, скрыта, вам придется ее отобразить, прежде чем продолжить:
- Откройте Проводник
.
- Щелкните по вкладке Вид.
- Установите флажок в поле «Скрытые элементы».
- Откройте Проводник
-
2
Перейдите в папку, в которой установлен Python. Python иногда размещают в папку «C:Python27», но если вы установили самую последнюю версию Python, используя настройки по умолчанию, программа будет спрятана в скрытой папке. Скопируйте правильный путь к файлу, выполнив следующие действия:
- Нажмите на Этот компьютер в левой части Проводника.
- Дважды щелкните по своему жесткому диску в разделе «Устройства и диски».
- Прокрутите вниз и дважды щелкните по папке «Пользователи».
- Дважды щелкните по папке с вашим именем пользователя.
- Прокрутите вниз и дважды щелкните по папке «AppData».
- Дважды щелкните по папке «Local».
- Прокрутите вниз и дважды щелкните по папке «Programs».
- Дважды щелкните по папке «Python».
- Дважды щелкните по папке «Python» с номером версии (например, «Python36»).
-
3
Скопируйте путь к папке Python. Нажмите на адресную строку в верхней части Проводника, чтобы выделить ее содержимое, а затем нажмите Ctrl+C, чтобы скопировать выделенный адрес.
-
4
Откройте контекстное меню. Для этого щелкните правой кнопкой мыши по иконке «Пуск»
. После этого появится всплывающее меню.
- Всплывающее контекстное меню можно также открыть, нажав ⊞ Win+X.
-
5
Нажмите на Система во всплывающем меню. Откроется новое окно.
-
6
Нажмите на Сведения о системе. Это ссылка в правом верхнем углу окна. Откроется окно «Система».
-
7
Нажмите на ссылку Дополнительные параметры системы в левой верхней части окна «Система». Появится еще одно окно.
-
8
Нажмите на Переменные среды в правом нижнем углу всплывающего окна.
-
9
Найдите заголовок «Path» на панели «Переменные среды пользователя». Это окно находится вверху окна «Переменные среды».
- Возможно, вам придется прокрутить курсор вверх или вниз над панелью «Переменные среды пользователя», чтобы найти переменную «Path».
-
10
Дважды щелкните по заголовку «Path». Откроется всплывающее окно.
-
11
Нажмите на Создать в правой части окна. Посередине окна откроется текстовое поле.
-
12
Вставьте скопированный путь. Для этого нажмите Ctrl+V. Скопированный путь появится в текстовом поле посередине окна.
-
13
Нажмите OK в трех открытых окнах. Таким образом вы сохраните изменения и закроете окно «Path», окно «Переменные среды» и окно «Свойства системы».
Реклама
Об этой статье
Эту страницу просматривали 120 843 раза.