python 不被识别为内部或外部命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15171157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
python is not recognised as an internal or external command
提问by Ohm
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...
这真的是一个很烦人的问题。我在网上四处寻找解决方案,但我发现的只是有关更改 PATH 变量的提示,当然,我确实这样做了。我的 Python 安装目录是 C:\Python27。这是一个32位版本。每当我在命令提示符下键入 python 时,它都会说它不被识别为内部或外部命令。目前,我的 PATH 变量设置为 C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts。任何人有任何想法?顺便说一下,我运行的是 Windows 7(64 位)。我很绝望。哎呀,如果没有任何效果,我想我会尝试双引导 Linux 和 Windows 7 ...
回答by Oddstr13
After changing the PATH variable in windows, you need to reboot your system before it takes effect.
在windows中修改PATH变量后,需要重启系统才能生效。
Edit: As stated by @tdelaney, only a restart of cmd.exe should be required. This is true atleast for Windows 7 64bit.
编辑:如@tdelaney 所述,只需要重新启动 cmd.exe。至少对于 64 位 Windows 7 来说是这样。
回答by user1210233
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.
快速修复:可能不是最优雅或最长期的修复,但如果您真的很沮丧并且只想让它运行,只需将 python.exe 文件复制粘贴到您的当前目录。这对我有用。
回答by thiagowfx
After adding the python folder to the system PATHvariable, you should reboot your computer.
将 python 文件夹添加到系统PATH变量后,您应该重新启动计算机。
Another simple solution is: create a shortcut of the python.exeexecutable (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 PATHvariable). The name of your shortcut should be python(maybe python.exeshould work too). I mean, it can't be python - shortcutor similar, for your purposes.
另一个简单的解决方案是:python.exe在C:\Python27\python.exe类似的地方C:\Windows\system32(即已经在PATH变量中列出的地方)创建可执行文件的快捷方式(可能在或类似位置)。您的快捷方式的名称应该是python(也许也python.exe应该有效)。我的意思是,就python - shortcut您的目的而言,它不可能是或类似的。
To see the contents of the PATHvariable, go to the cmdand enter set PATH.
要查看PATH变量的内容,请转到cmd并输入set PATH.
回答by Timothée HENRY
Just adding the Python path and trying again worked for me (without reboot).
只需添加 Python 路径并再次尝试对我有用(无需重新启动)。
MS-dos command for Python 2.7:
Python 2.7 的 MS-dos 命令:
set PATH=%PATH%;C:\python27\
MS-dos command for Python 3.3:
Python 3.3 的 MS-dos 命令:
set PATH=%PATH%;C:\python33\
(check if that is the folder where you installed Python).
(检查那是否是您安装 Python 的文件夹)。
回答by Matt Conway
In your PATH have you got a leading space before your Python path?
在您的 PATH 中,您的 Python 路径之前是否有前导空格?
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.
如果路径之间有前导空格"ry\bin; C:\Pyt",它将不起作用,并且通常是导致此类问题的原因。
回答by Osbad44
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.
安装的时候,有一个复选框默认没有选中,但是会要求将python添加到环境变量中。重新安装并选中该框。
I'd rather the installer do it than struggle in the weeds myself.
我宁愿安装人员自己做,也不愿自己在杂草中挣扎。
回答by Bhanu
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,
好的,正如你所说,你的 Python 安装目录是 C:\Python27,打开我的电脑,然后打开 c: 驱动器,如果你在那里没有看到“Python27”命名的文件夹,那么尝试使用搜索选项搜索它,(在我的情况下)我在 old.window 文件夹中找到它,不知道它是如何移动到那里的)在 c 驱动器中剪切并通过它以及诸如程序文件、用户等文件夹...,现在打开 cmd 并键入 python 并按回车键进行检查如果它现在工作,
回答by naMretupmoC
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.
这只是部分答案,但我发现(反复)当我使用 gui 安装程序而不进行自定义设置时,我会遇到类似的问题。
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.
使用自定义设置选项,然后使用相同的设置,“为所有用户安装”(然后安装到 C://python.version/blah 而不是基于用户的默认结构)将允许安装程序正确设置 PATH。

![Python 区域:IOError:[Errno 22] 无效模式('w')或文件名](/res/img/loading.gif)