python is not recognised as an internal or externa

2019-03-25 15:44发布

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

标签: python cmd
8条回答
Bombasti
2楼-- · 2019-03-25 16:00

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.

查看更多
对你真心纯属浪费
3楼-- · 2019-03-25 16:01

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).

查看更多
小情绪 Triste *
4楼-- · 2019-03-25 16:15

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.

查看更多
对你真心纯属浪费
5楼-- · 2019-03-25 16:19

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.

查看更多
一夜七次
6楼-- · 2019-03-25 16:21

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.

查看更多
可以哭但决不认输i
7楼-- · 2019-03-25 16:24

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.

查看更多
登录 后发表回答