简体   繁体   English

当 python.exe 设置为“以管理员身份运行”时,在 Windows 中运行 python 脚本会给出“无法使用...创建进程”

[英]Running a python script in Windows gives "Unable to Create Process Using ..." when python.exe set to 'run as administrator'

I used to be able to call python scripts directly from the command line in Windows.我曾经能够直接从 Windows 的命令行调用 python 脚本。 eg:例如:

C:\\SomeScript.py C:\\SomeScript.py

But after setting the python executable to 'Run as Administrator' in the compatibility settings, I always get the cryptic error "Unable to Create Process using' ... followed by path of the python file I'm trying to run:但是在兼容性设置中将 python 可执行文件设置为“以管理员身份运行”后,我总是收到神秘错误“无法使用创建进程”......后跟我试图运行的 python 文件的路径:

Unable to create process using 'C:\\python\\python.exe "C:\\SomeScript.py" '无法使用 'C:\\python\\python.exe "C:\\SomeScript.py" ' 创建进程

I get the same error if I try and run the file from Explorer (albeit flashing on my screen briefly, or if I run the script from the 'Send To' popup.如果我尝试从资源管理器运行该文件(尽管在我的屏幕上短暂闪烁,或者如果我从“发送到”弹出窗口运行脚本),我会遇到同样的错误。

This was caused by the Python executable being set to 'Run As Administrator.'这是由于 Python 可执行文件被设置为“以管理员身份运行”所致。 in the compatibility settings;在兼容性设置中; presumably because windows could not load the UAC form to escalate privileges.大概是因为 Windows 无法加载 UAC 表单来提升权限。

There are two possible solutions.有两种可能的解决方案。

  1. Remove the 'Run as Administrator' setting删除“以管理员身份运行”设置

  2. Pass the script's path as an argument to Python.exe rather than calling it directly, which allows windows to prompt for escalation correctly.将脚本的路径作为参数传递给 Python.exe 而不是直接调用它,这允许 Windows 正确提示升级。

Ie Instead of即代替

c:\\SomeScript.py c:\\SomeScript.py

run

c:\\python\\python.exe c:\\SomeScript.py c:\\python\\python.exe c:\\SomeScript.py

暂无
暂无

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

相关问题 无法使用“...\python.exe”创建进程 | 虚拟环境错误 - Unable to create process using '...\python.exe' | error in virtual environment 启动器中的致命错误:无法使用““ c:\\ python27 \\ python.exe”创建进程 - Fatal error in launcher: Unable to create process using '“c:\python27\python.exe” 从 VBA 运行 Python 脚本没有任何反应,但是当我从 python.exe 运行它时,它起作用了 - Running Python script from VBA nothing happens, but when I run it from python.exe, it works 我无法使用 python.exe 运行 python 程序 - I'm unable to run a python program using python.exe 无法使用“c:\\bld\\scrapy_1564674375870\\_h_env\\python.exe”创建进程 - Unable to create process using '"c:\bld\scrapy_1564674375870\_h_env\python.exe" 无法运行包含剧作家的python.exe - Unable to run python.exe containing playwright 无法完全安装OpenAI Gym-无法使用“ c:\\ python37-32 \\ python.exe”创建进程 - Unable to do full installation of OpenAI Gym - Unable to create process using '“c:\python37-32\python.exe” “启动器中的致命错误:无法使用 c:\pythonXX\python.exe 创建进程”在 python 重新安装后启动 jupyter 时 - “Fatal error in launcher: unable to create process with c:\pythonXX\python.exe” when launching jupyter after python re-install 在启动器中出现致命错误:无法使用“c:\python37\python.exe”“C:\Python37\Scripts\pyrcc5.exe”创建进程 - getting Fatal error in launcher: Unable to create process using '"c:\python37\python.exe" "C:\Python37\Scripts\pyrcc5.exe" 启动器中的致命错误:使用 python 运行 django-admin.exe 时无法使用“”创建进程 - Fatal error in launcher: Unable to create process using '"' when running django-admin.exe using python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM