似乎一夜之间Windows 10的更新破坏了Python。只是试图运行python——version返回一个“Permission Denied”错误。三个更新都没有;KB4507453、KB4506991或KB4509096似乎是罪魁祸首,但出现问题的时间令人怀疑。与其搞砸回滚,我希望有一个我错过的更简单的解决方法。
python的权限是“-rwxr-xr-x”,除了让Windows更新在安装昨晚的补丁后重新启动机器外,我没有改变任何东西。
根据系统信息,我正在运行10.0.18362
还应该注意,无论我(尝试)从git-bash执行Python使用“作为管理员运行”或不,如果我尝试使用PowerShell,它只是打开Windows商店,好像应用程序没有安装,所以我认为它不能看到我的/c/Users/david/AppData/Local/Microsoft/WindowsApps/文件夹的内容。
我还尝试重新安装Python 3.7.4,但也没有帮助。还有什么我该看的吗?
这不是PowerShell的解决方案,但除了MINGW64之外,我也遇到了同样的问题。我绕过它切换到Windows子系统Linux(我想做的无论如何)作为我的终端,只是一般和在VSCode。这篇文章描述得很好:
如何配置VS Code (windows)使用Ubuntu应用程序作为终端
总而言之:
1)从Windows应用商店安装Ubuntu
2)修改默认bash CMD -> wslconfig /setdefault Ubuntu
--- 对于VSCode
3) 重新启动 VSCode
4)在VSCode中将“terminal.integrated.shell.windows”更改为“C:\WINDOWS\System32\bash.exe”(更多详细信息见上面的帖子)
现在在VSCode和WSL (Bash on Ubuntu on Windows)中运行顺畅。对你来说至少是个暂时的解决办法。
这个问题太常见了,不可能一直存在。大多数答案和说明都未能解决这个问题。下面是在Windows 10上可以做的事情:
Type environment variables in the start search bar, and open Edit the System Environment Variables.
Click Environment Variables...
In the System Variables section, locate the variable with the key Path and double click it.
Look for paths pointing to python files. Likely there are none. If there are, select and delete them.
Create a new variable set to the path to your python executable. Normally this is C:\Users\[YOUR USERNAME HERE]\AppData\Local\Programs\Python\Python38. Ensure this by checking via your File Explorer.
Note: If you can't see AppData, it's because you've not enabled viewing of hidden items: click the View tab and tick the Hidden Items checkbox.
Create another variable pointing to the Scripts directory. Typically it is C:\Users\[YOUR USERNAME HERE]\AppData\Local\Programs\Python\Scripts.
Restart your terminal and try typing py, python, python3, or python.exe.