似乎一夜之间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,但也没有帮助。还有什么我该看的吗?


当前回答

对于那些想要使用微软商店版本的Python的人来说,在@Zooba修复了相关的“管理应用程序执行别名”之后,并且正在使用Git For Windows Git - BASH(也称为BASH through msys2 mintty),解决方案可能只是记住使用winpty进行调用。

winpty python3

但是,如果系统有其他版本的Python,请确保这些副本已被删除(例如从python.org安装的那些)或包含在其特定的捆绑应用程序中(例如OSGeo4W)(可能需要重新排序环境变量)。

Why, if winpty is forgotten, is it a permission error? For the first time it runs, the Microsoft Store stubs are conflicting with the permissions available to msys. A lot of the other answers go into the details of what is going on and why it feels weird. The short answer, is that the stub is trying to be a convenience short-cut to the Microsoft Store. If you launch it with winpty, it can do that. After that first time, it continues to need winpty for both related and unrelated reasons to the Microsoft Store.

其他回答

据我所知,这是由最近添加到Windows商店的Python 3.7版本冲突引起的。这看起来像是在%USERPROFILE%\AppData\Local\Microsoft\WindowsApps文件夹中添加了两个名为Python .exe和python3.exe的“存根”,在我的例子中,这是插入到PATH中现有的Python可执行文件条目之前的。

将这个条目移到正确的Python文件夹下面(部分地)纠正了这个问题。

纠正它的第二部分是在Windows搜索提示符中输入管理应用程序执行别名,并完全禁用Python的商店版本。

你可能只需要做第二部分,但在我的系统上,我做了这两个更改,现在一切都恢复正常了。

解决方法:如果您已经从exe安装了python,请执行以下步骤。

步骤1:卸载python

步骤2:安装python并选中下面屏幕截图(黄色)中突出显示的python路径复选框。

这就解决了我的问题。

也许您可以尝试使用管理员权限打开命令提示符。(以管理员身份运行)。大部分时间对我都管用。

这不是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)中运行顺畅。对你来说至少是个暂时的解决办法。

对于那些想要使用微软商店版本的Python的人来说,在@Zooba修复了相关的“管理应用程序执行别名”之后,并且正在使用Git For Windows Git - BASH(也称为BASH through msys2 mintty),解决方案可能只是记住使用winpty进行调用。

winpty python3

但是,如果系统有其他版本的Python,请确保这些副本已被删除(例如从python.org安装的那些)或包含在其特定的捆绑应用程序中(例如OSGeo4W)(可能需要重新排序环境变量)。

Why, if winpty is forgotten, is it a permission error? For the first time it runs, the Microsoft Store stubs are conflicting with the permissions available to msys. A lot of the other answers go into the details of what is going on and why it feels weird. The short answer, is that the stub is trying to be a convenience short-cut to the Microsoft Store. If you launch it with winpty, it can do that. After that first time, it continues to need winpty for both related and unrelated reasons to the Microsoft Store.