Не работает python в cmd windows

When I type python into the command line, the command prompt says python is not recognized as an internal or external command, operable program, or batch file. What should I do? Note: I have Python...

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

This is starting to get aggravating. I’m getting the typical ‘python’ is not recognized as an internal or external command… message when trying to run python on the command line. This is a common issue, and I’ve found plenty of posts saying to fix it by adding python folder (C:UsersftakeAnaconda3) my Windows path (restarted my PC after that) but nothing worked for me. The problem is that I’ve already Anaconda 1.8.2 installed on my computer and when trying to run python on CMD an error message occurs saying that python is not recognized as an internal…

I’ve tried to install pyinstaller (or any other Python packages) using pip, a message occurs too ‘pip’ is not recognized as an internal or external command…
Even though when trying to run (on CMD) the following command to create a virtual environment: virtualenv --python=python3.6.3 <env-name>

I’m using:
OS: Windows 10 Pro.
Anaconda Version: 1.8.2

asked Apr 2, 2018 at 18:08

Fouzi TAKELAIT's user avatar

Fouzi TAKELAITFouzi TAKELAIT

3131 gold badge3 silver badges12 bronze badges

2

I just spent 30 minutes on this, so I’ll provide a much more detailed answer than the above…

1) Open «My Computer»
2) Right Click «This PC»
3) Select «Properties»
Image 1 - My PC

4) Select «Advanced System Settings»
Image 2 - Advanced Settings

5) Select «Environment Variables»
6) Under «System Variables», highlight «Path» row
7) Select «Edit»
8) Select «Browse»
9) Navigate to Anaconda Path (Python should be there; check for python.exe at that location)

Image 3 - Adding Path

10) Restart your cmd.exe; everything should work.

answered Mar 25, 2019 at 21:57

Vladimir Romanov's user avatar

You probably haven’t added it to your environment variables, here how you do it:

  1. Go to «Edit the system environment variables» inside of control panel (you can search for it to using the search thing).

  2. Once you are there make sure you are in the advanced section.

  3. Click «Environment variables». In the section that says «System variables» search for something named «Path».

  4. If path is not there, simply create it by clicking «New» in the part that says system variables.

  5. Once you got that done, select «Path» and click edit, now find the path that you installed Anaconda in (i.e C:UsersftakeAnaconda3) and add it to the «Path».

  6. Once you got that done try using the python command again and it should work.

If I was unclear about something, you can follow this as well: https://www.java.com/en/download/help/path.xml

I know it’s for java but it works the exact same way for python.

EDIT:
Also for pip it’s literally the same thing just add Scripts to the end of the path

Løiten's user avatar

Løiten

3,1174 gold badges23 silver badges35 bronze badges

answered Apr 2, 2018 at 18:45

Bale's user avatar

BaleBale

5535 silver badges19 bronze badges

0

I had my path setup properly still it didn’t seem to work, later I found that I had
a partial entry of python files in the C:UsersUserAppDataLocalMicrosoftWindowsApps and my WindowsApps were in the path to, so when I ran python in it did not work.
To check where your python has been installed and has an entry,

Go to Anaconda Prompt and run

where python

it will return you the list of location, add the appropriate one

answered Jul 5, 2020 at 1:51

Praveen G's user avatar

Praveen GPraveen G

7291 gold badge12 silver badges24 bronze badges

1

Even i faced the same problem because of python path was not added in environment variable ,follow below steps :

  1. Go to Anaconda prompt type : where python

    say it is C:ProgramFilesAnaconda3python.exe

  2. Open «Advanced system setting» from main menu. In environment variable,edit path and add path : C:ProgramFilesAnaconda3

  3. Now in command prompt you see by typing : python —version

& the error «python’ is not recognized as an internal or external command on CMD» will also go off.

answered Mar 6, 2019 at 5:51

Shalini Baranwal's user avatar

Shalini BaranwalShalini Baranwal

2,6804 gold badges23 silver badges33 bronze badges

once and for all clarification when you get this python or pip is not recognised error in windows command prompt happens often when multiple IDE installations

Go to environmental variables then to system variables where you change or add this

sometimes your anaconda3 path maybe in allusers if you install it as administator so go through the C drive to get that

example C:UsersAll Usersanaconda3

If not try py -m pip install yourpackage

answered Dec 3, 2018 at 1:55

Redz Ch's user avatar

If you didn’t check the Add Anaconda to the Windows PATH during installation, you can do it manually by adding the following paths to your path-variable:

  • C:<path_to_anaconda_directory>anaconda3
  • C:<path_to_anaconda_directory>anaconda3Librarymingw-w64bin
  • C:<path_to_anaconda_directory>anaconda3Libraryusrbin
  • C:<path_to_anaconda_directory>anaconda3Librarybin
  • C:<path_to_anaconda_directory>anaconda3Scripts

The standard path (if you didn’t specify anything else in the installation) is C:Users<your_user_name>AppDataLocalContinuumanaconda3

answered Feb 19, 2019 at 13:49

Løiten's user avatar

LøitenLøiten

3,1174 gold badges23 silver badges35 bronze badges

This is starting to get aggravating. I’m getting the typical ‘python’ is not recognized as an internal or external command… message when trying to run python on the command line. This is a common issue, and I’ve found plenty of posts saying to fix it by adding python folder (C:UsersftakeAnaconda3) my Windows path (restarted my PC after that) but nothing worked for me. The problem is that I’ve already Anaconda 1.8.2 installed on my computer and when trying to run python on CMD an error message occurs saying that python is not recognized as an internal…

I’ve tried to install pyinstaller (or any other Python packages) using pip, a message occurs too ‘pip’ is not recognized as an internal or external command…
Even though when trying to run (on CMD) the following command to create a virtual environment: virtualenv --python=python3.6.3 <env-name>

I’m using:
OS: Windows 10 Pro.
Anaconda Version: 1.8.2

asked Apr 2, 2018 at 18:08

Fouzi TAKELAIT's user avatar

Fouzi TAKELAITFouzi TAKELAIT

3131 gold badge3 silver badges12 bronze badges

2

I just spent 30 minutes on this, so I’ll provide a much more detailed answer than the above…

1) Open «My Computer»
2) Right Click «This PC»
3) Select «Properties»
Image 1 - My PC

4) Select «Advanced System Settings»
Image 2 - Advanced Settings

5) Select «Environment Variables»
6) Under «System Variables», highlight «Path» row
7) Select «Edit»
8) Select «Browse»
9) Navigate to Anaconda Path (Python should be there; check for python.exe at that location)

Image 3 - Adding Path

10) Restart your cmd.exe; everything should work.

answered Mar 25, 2019 at 21:57

Vladimir Romanov's user avatar

You probably haven’t added it to your environment variables, here how you do it:

  1. Go to «Edit the system environment variables» inside of control panel (you can search for it to using the search thing).

  2. Once you are there make sure you are in the advanced section.

  3. Click «Environment variables». In the section that says «System variables» search for something named «Path».

  4. If path is not there, simply create it by clicking «New» in the part that says system variables.

  5. Once you got that done, select «Path» and click edit, now find the path that you installed Anaconda in (i.e C:UsersftakeAnaconda3) and add it to the «Path».

  6. Once you got that done try using the python command again and it should work.

If I was unclear about something, you can follow this as well: https://www.java.com/en/download/help/path.xml

I know it’s for java but it works the exact same way for python.

EDIT:
Also for pip it’s literally the same thing just add Scripts to the end of the path

Løiten's user avatar

Løiten

3,1174 gold badges23 silver badges35 bronze badges

answered Apr 2, 2018 at 18:45

Bale's user avatar

BaleBale

5535 silver badges19 bronze badges

0

I had my path setup properly still it didn’t seem to work, later I found that I had
a partial entry of python files in the C:UsersUserAppDataLocalMicrosoftWindowsApps and my WindowsApps were in the path to, so when I ran python in it did not work.
To check where your python has been installed and has an entry,

Go to Anaconda Prompt and run

where python

it will return you the list of location, add the appropriate one

answered Jul 5, 2020 at 1:51

Praveen G's user avatar

Praveen GPraveen G

7291 gold badge12 silver badges24 bronze badges

1

Even i faced the same problem because of python path was not added in environment variable ,follow below steps :

  1. Go to Anaconda prompt type : where python

    say it is C:ProgramFilesAnaconda3python.exe

  2. Open «Advanced system setting» from main menu. In environment variable,edit path and add path : C:ProgramFilesAnaconda3

  3. Now in command prompt you see by typing : python —version

& the error «python’ is not recognized as an internal or external command on CMD» will also go off.

answered Mar 6, 2019 at 5:51

Shalini Baranwal's user avatar

Shalini BaranwalShalini Baranwal

2,6804 gold badges23 silver badges33 bronze badges

once and for all clarification when you get this python or pip is not recognised error in windows command prompt happens often when multiple IDE installations

Go to environmental variables then to system variables where you change or add this

sometimes your anaconda3 path maybe in allusers if you install it as administator so go through the C drive to get that

example C:UsersAll Usersanaconda3

If not try py -m pip install yourpackage

answered Dec 3, 2018 at 1:55

Redz Ch's user avatar

If you didn’t check the Add Anaconda to the Windows PATH during installation, you can do it manually by adding the following paths to your path-variable:

  • C:<path_to_anaconda_directory>anaconda3
  • C:<path_to_anaconda_directory>anaconda3Librarymingw-w64bin
  • C:<path_to_anaconda_directory>anaconda3Libraryusrbin
  • C:<path_to_anaconda_directory>anaconda3Librarybin
  • C:<path_to_anaconda_directory>anaconda3Scripts

The standard path (if you didn’t specify anything else in the installation) is C:Users<your_user_name>AppDataLocalContinuumanaconda3

answered Feb 19, 2019 at 13:49

Løiten's user avatar

LøitenLøiten

3,1174 gold badges23 silver badges35 bronze badges


Загрузить PDF


Загрузить PDF

Из этой статьи вы узнаете, как открыть файл Python при помощи встроенной Командной строки на компьютере под управлением Windows. В большинстве случаев это можно сделать без каких-либо проблем — главное, чтобы на вашем компьютере был установлен Python. Если вы установили старую версию Python или использовали пользовательские настройки в ходе установки, из-за которых команда «python» не была добавлена в список переменных «Path» на компьютере, вам придется добавить Python в список переменных «Path», чтобы иметь возможность запускать файл Python через командную строку.

  1. Изображение с названием Use Windows Command Prompt to Run a Python File Step 1

    1

    Перейдите к папке с файлом Python. Найдите файл Python, который хотите открыть в Командной строке.

    • Если вам уже известен путь к файлу Python, который вы хотите открыть, перейдите к разделу об открытии файла в Командной строке..
  2. Изображение с названием Use Windows Command Prompt to Run a Python File Step 2

    2

    Выберите файл Python. Нажмите один раз на файл Python, путь к которому вы хотите узнать.

  3. Изображение с названием Use Windows Command Prompt to Run a Python File Step 3

    3

    Щелкните правой кнопкой мыши по файлу Python. Появится выпадающее меню.

  4. Изображение с названием Use Windows Command Prompt to Run a Python File Step 4

    4

    Выберите Свойства из выпадающего меню. Откроется окно свойств.

  5. Изображение с названием Use Windows Command Prompt to Run a Python File Step 5

    5

    Обратите внимание на значение в строке «Расположение». Адрес папки (или «путь») справа от пункта «Расположение» — это именно то, что вам нужно ввести в Командную строку, чтобы перейти к каталогу, в котором хранится файл Python.

    • Чтобы скопировать расположение, его необходимо выделить (зажмите и перетащите указатель мыши по значению в строке «Расположение»), а затем нажать Ctrl+C.

    Реклама

  1. Изображение с названием Use Windows Command Prompt to Run a Python File Step 6

    1

    Откройте меню «Пуск»

    Изображение с названием Windowsstart.png

    . Щелкните по логотипу Windows в нижнем левом углу экрана. Появится меню «Пуск».

  2. Изображение с названием Use Windows Command Prompt to Run a Python File Step 7

    2

    Найдите Командную строку, введя cmd.

  3. Изображение с названием Use Windows Command Prompt to Run a Python File Step 8

    3

    Нажмите на

    Изображение с названием Windowscmd1.png

    Командная строка в верхней части меню «Пуск», чтобы открыть Командную строку.

  4. Изображение с названием Use Windows Command Prompt to Run a Python File Step 9

    4

    Перейдите к расположению файла Python. Введите cd и нажмите пробел, после чего введите адрес «Расположение» файла Python и нажмите Enter.

    • К примеру, чтобы открыть файл Python в папке с именем «Файлы» на рабочем столе, вам нужно ввести cd desktop/Файлы.
    • Если вы скопировали путь к файлу, введите cd и нажмите пробел, после чего нажмите Ctrl+V, чтобы вставить путь.
  5. Изображение с названием Use Windows Command Prompt to Run a Python File Step 10

    5

    Введите команду «python» и имя файла. Введите python файл.py, где файл — это имя файла Python.

    • К примеру, если файл Python называется «script», введите python script.py.
    • Если в имени файла Python есть один или несколько пробелов, окружите имя и расширение файла кавычками (например, python "my script.py").
  6. Изображение с названием Use Windows Command Prompt to Run a Python File Step 11

    6

    Нажмите Enter, чтобы запустить команду и открыть файл Python через установленную на компьютере программу Python.

    • Если после нажатия клавиши «Enter» вы столкнетесь с ошибкой, сообщающей, что 'python' не распознается как внутренняя или внешняя команда, вам нужно будет добавить Python в список «PATH», прежде чем вернуться к этой части.

    Реклама

  1. Изображение с названием Use Windows Command Prompt to Run a Python File Step 12

    1

    Включите отображение скрытых папок. Поскольку одна из папок, в которой находится установочный каталог Python, скорее всего, скрыта, вам придется ее отобразить, прежде чем продолжить:

    • Откройте Проводник
      Изображение с названием File_Explorer_Icon.png

      .

    • Щелкните по вкладке Вид.
    • Установите флажок в поле «Скрытые элементы».
  2. Изображение с названием Use Windows Command Prompt to Run a Python File Step 13

    2

    Перейдите в папку, в которой установлен Python. Python иногда размещают в папку «C:Python27», но если вы установили самую последнюю версию Python, используя настройки по умолчанию, программа будет спрятана в скрытой папке. Скопируйте правильный путь к файлу, выполнив следующие действия:

    • Нажмите на Этот компьютер в левой части Проводника.
    • Дважды щелкните по своему жесткому диску в разделе «Устройства и диски».
    • Прокрутите вниз и дважды щелкните по папке «Пользователи».
    • Дважды щелкните по папке с вашим именем пользователя.
    • Прокрутите вниз и дважды щелкните по папке «AppData».
    • Дважды щелкните по папке «Local».
    • Прокрутите вниз и дважды щелкните по папке «Programs».
    • Дважды щелкните по папке «Python».
    • Дважды щелкните по папке «Python» с номером версии (например, «Python36»).
  3. Изображение с названием Use Windows Command Prompt to Run a Python File Step 14

    3

    Скопируйте путь к папке Python. Нажмите на адресную строку в верхней части Проводника, чтобы выделить ее содержимое, а затем нажмите Ctrl+C, чтобы скопировать выделенный адрес.

  4. Изображение с названием Use Windows Command Prompt to Run a Python File Step 15

    4

    Откройте контекстное меню. Для этого щелкните правой кнопкой мыши по иконке «Пуск»

    Изображение с названием Windowsstart.png

    . После этого появится всплывающее меню.

    • Всплывающее контекстное меню можно также открыть, нажав Win+X.
  5. Изображение с названием Use Windows Command Prompt to Run a Python File Step 16

    5

    Нажмите на Система во всплывающем меню. Откроется новое окно.

  6. Изображение с названием Use Windows Command Prompt to Run a Python File Step 17

    6

    Нажмите на Сведения о системе. Это ссылка в правом верхнем углу окна. Откроется окно «Система».

  7. Изображение с названием Use Windows Command Prompt to Run a Python File Step 18

    7

    Нажмите на ссылку Дополнительные параметры системы в левой верхней части окна «Система». Появится еще одно окно.

  8. Изображение с названием Use Windows Command Prompt to Run a Python File Step 19

    8

    Нажмите на Переменные среды в правом нижнем углу всплывающего окна.

  9. Изображение с названием Use Windows Command Prompt to Run a Python File Step 20

    9

    Найдите заголовок «Path» на панели «Переменные среды пользователя». Это окно находится вверху окна «Переменные среды».

    • Возможно, вам придется прокрутить курсор вверх или вниз над панелью «Переменные среды пользователя», чтобы найти переменную «Path».
  10. Изображение с названием Use Windows Command Prompt to Run a Python File Step 21

    10

    Дважды щелкните по заголовку «Path». Откроется всплывающее окно.

  11. Изображение с названием Use Windows Command Prompt to Run a Python File Step 22

    11

    Нажмите на Создать в правой части окна. Посередине окна откроется текстовое поле.

  12. Изображение с названием Use Windows Command Prompt to Run a Python File Step 23

    12

    Вставьте скопированный путь. Для этого нажмите Ctrl+V. Скопированный путь появится в текстовом поле посередине окна.

  13. Изображение с названием Use Windows Command Prompt to Run a Python File Step 24

    13

    Нажмите OK в трех открытых окнах. Таким образом вы сохраните изменения и закроете окно «Path», окно «Переменные среды» и окно «Свойства системы».

    Реклама

Об этой статье

Эту страницу просматривали 121 323 раза.

Была ли эта статья полезной?

Я установил последнюю версию Python для Win10 из Релизы для Windows. Просто набрав py в Command Prompt Window запускает питон.

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`

Тестирование:

>>> print("hello!")
hello!
>>>

Имейте в виду, что в моем случае Python был установлен в C:Userssg7AppDataLocalProgramsPythonPython36> каталог

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

Когда я нахожусь в C:Userssg7> уровень каталога python можно вызвать, набрав
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.
>>>

Более новый Python 3.7 будет установлен по адресу:
C:UsersYourUserNameHereAppDataLocalProgramsPythonPython37

Если вы хотите, вы можете добавить к переменной окружения вашего пути:
%USERPROFILE%AppDataLocalProgramsPythonPython36

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:pathtopython 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: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.

Понравилась статья? Поделить с друзьями:
  • Не работает punto свитчер на windows 10
  • Не работает x360ce на windows 10
  • Не работает usb мышь на ноутбуке windows 10
  • Не работает ps2 мышка windows 10
  • Не работает wsl на windows 11