Python / python3在命令提示符下执行,但无法正常运行 [英] Python/python3 executes in Command Prompt, but does not run correctly

查看:883
本文介绍了Python / python3在命令提示符下执行,但无法正常运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经解决了该问题,正在发布以使他人摆脱痛苦。

I've solved the issue and am posting to save others from my hours of pain.

在Windows 10上,

On Windows 10,

Python安装在 C:\Python 中,并添加到环境变量中,但是将无法正常运行程序。

Python is installed in C:\Python and added to Environment Variables, but will not properly run programs.

在CMD中键入 python myscript.py 不会运行程序,但不会产生任何错误。

Typing python myscript.py in CMD does not run the program but does not produce any errors.

键入 C:\Python\python.exe myscript.py 可以正确运行代码。

Typing C:\Python\python.exe myscript.py correctly runs the code.

导航到 C:\Users\Username\AppData C本地\Microsoft\WindowsApps\python.exe ,然后键入 del / f python.exe

文件位于 C:\Users\MyUsername\AppData\在 PATH 中的环境变量之前,先查看本地 Microsoft WindowsApps python.exe 。该文件只是打开Edge中Python的下载页面。

The file located at C:\Users\MyUsername\AppData\Local\Microsoft\WindowsApps\python.exe is viewed before the Environment Variables in PATH. This file just opens the download page for Python in Edge.

您需要删除此文件或将其重命名,但是此文件夹中的项目受Microsoft保护。如果尝试使用文件资源管理器删除此文件,则会出现 Error 0x80070780 。为了删除它,您需要使用管理员权限导航到CMD中的文件夹,然后键入上面的内容以删除此文件。

You need to delete this file or rename it, but the items in this folder are protected by Microsoft. You get Error 0x80070780 if you try to delete this file with file explorer. In order to delete it you need to navigate to the folder in CMD with administrator privileges and type the above to remove this file.

我希望这对某人有帮助。

I hope this helps someone.

推荐答案

将这个问题/ A设置为正确的格式,这样问题就不会显得未解决/未解决



原始海报中的解决方案;测试并在我的系统上工作

解决方案

Solution

C:\Users\ * Username * \AppData\Local\Microsoft\WindowsApps 中删除​​ python。 exe 。但是,由于这些文件受到保护,因此在尝试删除文件时,您可能会收到错误消息。在这种情况下,您要么使用管理员帐户删除 python.exe ,要么调用具有管理员权限的cmd窗口并强制删除''''rm- f C:\Users * Username * \AppData\Local\Microsoft\WindowsApps\python.exe''''

In C:\Users\*Username*\AppData\Local\Microsoft\WindowsApps delete python.exe. However, because these files are protected, chances are you will get an error message when trying to delete the file. In that case, you either have to use your administrator account to delete python.exe, or you call a cmd-window with administrator privileges and force delete ''''rm -f C:\Users*Username*\AppData\Local\Microsoft\WindowsApps\python.exe''''

关于解决方案

About the solution

python.exe 不是python-可执行文件相信会如此,但是会调用python的下载页面,以便在Edge浏览器或Microsoft App Store中打开。问题谁会提出这样的虐待狂和为什么?。此时应保持未回答。事实是,调用python会在调用PATH环境变量之前执行该虚假 python.exe

python.exe is not the python - executable one would believe it to be, but invokes the download page for python to be opened in the Edge browser or the Microsoft App Store. The question of "who would come up with such a sadistic thing" and "why?." shall remain unanswered at this point. Fact is that calling python executes this faux- python.exe before the PATH Environment Variables are invoked.

这篇关于Python / python3在命令提示符下执行,但无法正常运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆