Не запускается python на windows из командной строки

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:\Users\sg7>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:\Users\sg7\AppData\Local\Programs\Python\Python36> directory

C:\Users\sg7\AppData\Local\Programs\Python\Python36>dir
 Volume in drive C is Windows7_OS
 Volume Serial Number is 1226-12D1

 Directory of C:\Users\sg7\AppData\Local\Programs\Python\Python36

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:\Users\sg7> directory level python can be invoked by typing
AppData\Local\Programs\Python\Python36\python

C:\Users\samg>AppData\Local\Programs\Python\Python36\python
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:\Users\YourUserNameHere\AppData\Local\Programs\Python\Python37

If you wish you can add to your path environment variable:
%USERPROFILE%\AppData\Local\Programs\Python\Python36

Whenever I run python in cmd 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.

add Python to your environment variables - screenshot

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:\path\to\python to the end of your Path variable under System variables, where python is your Python installation folder (only use PATH 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 the Environment Variables... button to get to the settings described.

  • On Windows 10, just add C:\path\to\python to the end of the list (in a new field).

  • Do not add python.exe to your path entry (i.e. C:\path\to\python\python.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:\path\to\python\Scripts 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:\Python34\python.exe

(the second one is probably meaningless but I tried) and still I get this error in Windows command line :

C:\Users\me>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

jeff's user avatar

3

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

yossim's user avatar

yossimyossim

3062 silver badges5 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:\Windows\py.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

Josef Ginerman's user avatar

answered Sep 21, 2017 at 14:17

senis000's user avatar

senis000senis000

2513 silver badges6 bronze badges

1

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%\AppData\Local\Microsoft\WindowsApps 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!
App execution aliases

answered Dec 2, 2022 at 14:05

tatoline's user avatar

tatolinetatoline

4436 silver badges11 bronze badges

8

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 Roy's user avatar

Arnab RoyArnab Roy

3073 silver badges8 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%\AppData\Local\Microsoft\WindowsApps down vs. having it the first path listed there.

vvvvv's user avatar

vvvvv

26k19 gold badges51 silver badges83 bronze badges

answered Apr 3, 2022 at 6:50

uditgt's user avatar

uditgtuditgt

1491 silver badge1 bronze badge

4

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.

Community's user avatar

answered Jun 12, 2014 at 15:00

bcorso's user avatar

bcorsobcorso

45.7k10 gold badges63 silver badges76 bronze badges

1

Also, make sure to leave no spaces after the semi-colon.

For example, this didn’t work for me:
C:\Windows\system32; C:\Python27; C:\Python27\Scripts;

But, this did:
C:\Windows\system32;C:\Python27;C:\Python27\Scripts;

answered Mar 29, 2018 at 17:21

nihal111's user avatar

nihal111nihal111

3683 silver badges9 bronze badges

2

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

David Schilpp's user avatar

1

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:\Python27\python.exe didn’t work but C:\Python27\ did work.

answered Oct 31, 2018 at 12:33

Nick W's user avatar

Nick WNick W

8772 gold badges15 silver badges30 bronze badges

1

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

Manikanta Vasupalli's user avatar

1

I was facing similar porblem. What helped me is where command.

C:\WINDOWS\system32>where python
C:\Users\xxxxxxx\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Program Files (x86)\Microsoft Visual
Studio\Shared\Python39_86\python.exe

On updating PATH variable to point to only one desired directory (basically I removed %USERPROFILE%\AppData\Local\Microsoft\WindowsApps from PATH) fixed my problem.

answered Mar 31, 2022 at 8:00

Manojkumar Khotele's user avatar

If you run into this issue like I just did, save yourself some time and reboot your entire computer, not just your terminal. This fixed it instantly for me.

answered Feb 28 at 2:50

KCP's user avatar

1

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

dev ip's user avatar

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 Files\Python37 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

mindmischief's user avatar

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's user avatar

Matthew

1,9053 gold badges19 silver badges26 bronze badges

answered Jun 20, 2019 at 9:15

Creepy Creature's user avatar

  1. Uninstall python and pyqt
  2. 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.
  3. Then see python version bit and download that version from python.org from all release menu.
  4. Then first install python and then install pyqt. It will work like butter.

Mohannad A. Hassan's user avatar

answered Nov 30, 2019 at 23:41

Mark S. Khalil's user avatar

1

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:\Python34\python.exe to C:\Python34\python34.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

maulynvia's user avatar

1

prim0

a53e06407f7f46df82d99b9f6184b52a.PNG3513624638ff4f809b8aa04a94af49a3.PNG


  • Вопрос задан

  • 19428 просмотров


Комментировать


Решения вопроса 2

saboteur_kiev

Saboteur

@saboteur_kiev Куратор тега Python

software engineer

А собственно сам питон вы на комп устанавливали?
Где находится python.exe можете показать?

Пригласить эксперта


Ответы на вопрос 3

RusTech

pyton как и piton не запустятся с командной строки

КАКОЙ PYTON?????? PYTHON!!!!!!!!!!!!!!!!!!!!]


Комментировать


Похожие вопросы


  • Показать ещё
    Загружается…

09 окт. 2023, в 19:26

1500 руб./в час

09 окт. 2023, в 18:18

1000 руб./за проект

09 окт. 2023, в 18:11

15000 руб./за проект

Минуточку внимания

Уведомления

  • Начало
  • » Python для новичков
  • » Не запускается python из cmd

#1 Фев. 26, 2013 21:35:09

Не запускается python из cmd

Здравствуйте. Установил python3.3 на Windows7-64bit. Прописал Path в системные переменные: Имя переменной “python”, значение переменной “C:\Python33;C:\Python33\Lib\site-packages\;C:\Python33\Scripts\;”. Все равно не запускается, пишет “”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

  • Не запускается star wars the clone wars republic heroes на windows 10
  • Не запускается pubg lite на пк windows 10 белый экран
  • Не запускается spotify на windows 10
  • Не запускается point blank на windows 10
  • Не запускается spooler windows 10