当我输入 python 时,CMD 打开窗口存储 [英] CMD opens window store when I type python

查看:36
本文介绍了当我输入 python 时,CMD 打开窗口存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天当我尝试在 Sublime Text 3 上运行一个简单的代码时,出现以下消息:

<块引用>

未找到 Python,但可以从 Microsoft Store 安装:

我认为我们在安装 python 时遇到了这个问题,因为在新的 Windows 安装中,别名位于 ON 位置,如下图所示.打开后,Windows 会在名为 %USERPROFILE%\AppData\Local\Microsoft\WindowsApps 的目录中放置一个名为 python.exe 和 python3.exe 的空文件或假文件.这是别名.

然后微软将该目录放在路径"列表的顶部.环境变量.

当您输入python"时在 cmd 中,它会搜索您的路径"中列出的目录.环境变量页面从上到下.因此,如果您在新的 Windows 10 安装后安装 Python 然后被重定向到 Windows 应用商店,那是因为有两个 python.exe,App Execution Alias 页面中的别名,以及在您安装 Python 但 cmd 找到 App 执行的任何地方的真实别名首先是别名 python.exe,因为该目录位于 Path 的顶部.

我认为最简单的解决方案是按照我之前的建议将 python.exe 和 python3.exe 设置为 OFF,这会删除假 exe.基于此 Microsoft Devblog https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/ 他们表示,他们部分地为新的python用户创建了这个系统,特别是在学校学习python但安装有问题的孩子.创建这个别名是为了帮助刚开始使用 python 的孩子安装它并专注于学习编码.如果您从 Windows App Store 安装 Python,我认为 Windows 可能会删除这些别名.我们注意到,如果您从其他来源手动安装,它们不会被删除.

(此外,空的/假的 python.exe 并不是真正的空,它在屏幕截图中显示为 0 KB,但在 cmd 中输入start ms-windows-store:"会打开 Windows App Store,因此它可能只有一行以及将其定向到 Python 页面的方法.)

最后,正如 Chipjust 建议的那样,您可以使用 DOSKEY 之类的东西为 python 创建一个新别名,如本文所述,例如:https://winaero.com/how-to-set-aliases-for-the-command-prompt-in-windows/

Today when I tried to run a simple code on Sublime Text 3, the following message appeared:

Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640

And when I type Python in CMD, it opens the Windows Store for me to download Python 3.7. This problem started today for no good reason, I didn't change or downloaded anything about Python and already tried reinstalling Python, and the Path is correct.

解决方案

Use the Windows search bar to find "Manage app execution aliases". There should be two aliases for python, unselect them, this will allow the usual python aliases "python" and "python3". See image below.

I think we have this problem when installing python because in a new Windows installation the aliases are in the ON position as in image below. When turned on, Windows puts a empty or fake file named python.exe and python3.exe in the directory named %USERPROFILE%\AppData\Local\Microsoft\WindowsApps. This is the alias.

Then Microsoft put that directory at the top of the list in the "Path" environment variables.

When you enter "python" in cmd, it searches the directories listed in your "Path" environment variables page from top to bottom. So if you installed Python after a new Windows 10 install then get redirected to the Windows Store it's because there are two python.exe's, the alias in the App Execution Alias page, and the real one wherever you installed Python but cmd finds the App execution alias python.exe first because that directory is at the top of the Path.

I think the easiest solution is to just check the python.exe and python3.exe to OFF as I suggested before, which deletes the fake exe's. Based on this Microsoft Devblog https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/ they stated they created this system partially for new python users specifically kids learning python in school that had trouble installing it. Creating this alias was to helps kids just starting python install it and focus on learning to code. I think Windows probably deletes those aliases if you install Python from the Windows App Store. What we are noticing is that they do not get deleted if you manually install from another source.

(Also the empty/fake python.exe is not really empty it says 0 KB in the screenshot but entering "start ms-windows-store:" in cmd opens the Windows App Store so it probably just has a line with that and a way to direct it to Python page.)

Finally, as Chipjust suggested you can create a new alias for python using something like DOSKEY as explained in this article for example: https://winaero.com/how-to-set-aliases-for-the-command-prompt-in-windows/

这篇关于当我输入 python 时,CMD 打开窗口存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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