0

enter image description here

The Chinese words read 'python' is not recognized as an internal or external command operable program or batch file.

I followed instructions on the Internet to solve this and did the followings. However, python is still not recognized. My computer runs windows 10 and my python version is 3.7.

I am a complete novice in programming. Your help means a lot to me. Thank you in advance.

enter image description here

(C:\Users\User\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python3.7)

user10113520
  • 39
  • 1
  • 4
  • Can you run `py` from the command line? The recommended way to run Python on Windows nowadays is with [the `py` launcher](https://www.python.org/dev/peps/pep-0397/), which can handle things like multiple Python installations without you needing to understand how to monkey with environment variables and Explorer file associations. – abarnert Jul 21 '18 at 03:58
  • Also, instead of following random "instructions on the internet", which may be out of date, it's usually better to follow the instructions on python.org. – abarnert Jul 21 '18 at 04:05
  • abarnert, you are right. The links you gave me below address my problem directly. I should always look up instructions on the official site first. – user10113520 Jul 21 '18 at 05:04
  • What instructions? – Max von Hippel Jul 21 '18 at 05:05
  • One solution is install `git` and run python at the git bash – Waket Zheng Jul 21 '18 at 06:43
  • 1
    @MaxvonHippel The Python docs include [Python Setup and Usage](https://docs.python.org/3/using/index.html) for each version. (For `pip` and PyPI, see the Python Packaging User Guide](https://www.pypa.io/en/latest/).) – abarnert Jul 21 '18 at 18:01

2 Answers2

1

Since Python 3.3, the installer automatically installs the py launcher on your path, and since 3.6, it doesn't put python itself on your path unless you enable a checkbox in the installer.

And that's fine, because you usually want to use py rather than python anyway. See Python Launcher for Windows in the help.

If you really need python on your path, the recommended solution is to just re-run the installer, select Modify, and click the checkbox. If you want to do it manually, you can, but it really isn't necessary. See Finding the Python executable in the docs for details.

abarnert
  • 354,177
  • 51
  • 601
  • 671
0

You probably did not add Python to PATH Look for your installed Python inside C:\Program Files folder

Take note of the path of Python

Ex. C:\Program Files\Pyhton37

Adding python directory to PATH

Right click on This PC Then click on Properties At the pop up window, look for Environment Variables At the first box look for PATH, double click it and press ADD. Add both C:\Program Files\Python37 and C:\Program Files\Python37\Scripts inside.

Now try again

Yon P
  • 206
  • 1
  • 9
  • You really don't need to do this. And probably don't want to, because it still won't help with things like Explorer file associations. Better to use `py` as recommended, or, if you really need a `python` command, to use the installer as intended. – abarnert Jul 21 '18 at 04:02
  • Ah yes I read your answer. And it is indeed the correct way. However, I thought when he asked “how to add pyhton to cmd”, he was really asking how to add python on cmd. My bad.@abarnert – Yon P Jul 22 '18 at 05:12