python is not recognised as an internal or externa

2019-03-25 15:52发布

问题:

This is a really annoying problem. I've prowled the web for solutions, but all I found was tips about changing the PATH variable, which I did, of course. My Python install directory is C:\Python27. It' a 32 bit version. Whenever I type python in the command prompt, it says that it isn't recognised as an internal or external command. Currently, my PATH variable is set to C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts. Anyone has any ideas? I run Windows 7 by the way (64 bit). I'm pretty desperate. Heck, if nothing works I guess I'll try dual-booting Linux and Windows 7...

回答1:

Just adding the Python path and trying again worked for me (without reboot).

MS-dos command for Python 2.7:

set PATH=%PATH%;C:\python27\

MS-dos command for Python 3.3:

set PATH=%PATH%;C:\python33\

(check if that is the folder where you installed Python).



回答2:

Quick fix: May not be the most elegant or long term fix but if you are really frustrated and just want to get it to run, just copy paste the python.exe file to your current directory. This worked for me.



回答3:

After adding the python folder to the system PATH variable, you should reboot your computer.

Another simple solution is: create a shortcut of the python.exe executable (probably it is in C:\Python27\python.exe, or similar) in a place like C:\Windows\system32 (that is, a place that already is listed in the PATH variable). The name of your shortcut should be python (maybe python.exe should work too). I mean, it can't be python - shortcut or similar, for your purposes.

To see the contents of the PATH variable, go to the cmd and enter set PATH.



回答4:

After changing the PATH variable in windows, you need to reboot your system before it takes effect.

Edit: As stated by @tdelaney, only a restart of cmd.exe should be required. This is true atleast for Windows 7 64bit.



回答5:

In your PATH have you got a leading space before your Python path?

For example:

"C:\somedirectory\bin; C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts"

If you have a leading space between path's "ry\bin; C:\Pyt", it won't work and is usually the cause for this type of issue.



回答6:

When installing, there is a checkbox that is by default not selected, but it asks to add python to the environment variable. Re-install and check that box.

I'd rather the installer do it than struggle in the weeds myself.



回答7:

Okay, as you said your Python install directory is C:\Python27, open my computer, then open c: drive, if you don't see "Python27" named folder there then try to search it using search option, (in my case i found it in old.window folder, don't know how it moved there) cut and past it in c drive along with folders like, program files, user etc... , now open cmd and type python and hit enter to check if it is working now,



回答8:

This is only a partial answer, but I found (repeatedly) that I'd have similar issues when I would use the gui installer and not go through the custom setup.

Using the custom setup option, then using the same settings, the "install for all users" (that then installs to C://python.version/blah instead of the user based default structure) WOULD allow the installer to setup PATH correctly.



标签: python cmd