简体   繁体   English

“python”仅以管理员身份从命令提示符运行

[英]“python” only runs from command prompt as Admin

I'm on Windows 7 and if I type "python" in the command prompt as my regular user, I get the old, "'python' is not recognized as an internal or external command, operable program or batch file."我在 Windows 7 上,如果我以普通用户的身份在命令提示符中键入“python”,我会得到旧的,“'python' 不被识别为内部或外部命令、可运行的程序或批处理文件。” but if I open the prompt as the administrator, python initiates like it should.但是如果我以管理员身份打开提示,python 会像它应该的那样启动。

The very first thing I did was edit the PATH variables through Control Panel, which seemed to add the environment variable, but there's a disconnect between doing this and cmd recognizing that I've done it.我做的第一件事是通过控制面板编辑 PATH 变量,它似乎添加了环境变量,但是这样做与 cmd 认识到我已经完成了它之间存在脱节。

I have changed the permissions on the Python27 folder to allow full access to all users, I've tried adding a pythonexe variable and add that to the PATH, as another StackOverflow question suggested.我已经更改了 Python27 文件夹的权限以允许对所有用户进行完全访问,我尝试添加一个 pythonexe 变量并将其添加到 PATH,正如另一个 StackOverflow 问题所建议的那样。

When I type PATH = C:\\Python27 into cmd as a regular user, that also wont work.当我以普通用户身份在 cmd 中键入 PATH = C:\\Python27 时,这也不起作用。

and if I type in set PATH, "C:\\Python27;"如果我输入 set PATH,“C:\\Python27;” is in the returned line.在返回的行中。

I'm fairly certain it's a permission problem, which is the only reason I've re-posted my own version of this age old question.我相当确定这是一个许可问题,这是我重新发布我自己版本的这个古老问题的唯一原因。 How do I run Python, given this error and these circumstances?鉴于此错误和这些情况,我该如何运行 Python?

To append your path with python directory: path=%PATH$;c:\\Python27 Run as normal user.用 python 目录附加你的路径: path=%PATH$;c:\\Python27以普通用户path=%PATH$;c:\\Python27运行。

You should also double check that c:\\python27\\python.exe actually exists.您还应该仔细检查c:\\python27\\python.exe确实存在。

So, one of the things I noticed when I had that problem is that the USERNAME environment variable was only set to system which is the administrator environment variable.因此,当我遇到该问题时,我注意到的一件事是 USERNAME 环境变量仅设置为系统,即管理员环境变量。 I simply looked up the username in the regular command prompt, using echo %USERNAME% and appended a semicolon and the username to the %USERNAME& environment variable.我只是在常规命令提示符中查找用户名,使用 echo %USERNAME% 并将分号和用户名附加到 %USERNAME& 环境变量。 That fixed the issue.这解决了问题。 Everything you can do in the administrator is now able to be done in the regular user command line as well.您可以在管理员中执行的所有操作现在也可以在常规用户命令行中完成。

我过去遇到过类似的问题,发现检查环境/系统变量中值的顺序也很重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM