来自powershell的Python命令的工作或失败取决于powershell的启动方式/位置

2024-04-23 07:14:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚刚安装了python并选中了设置环境变量的复选框。我试着根据自己的方便来查看启动python的不同方式(开始菜单、命令提示符、pythonshell等等),这时我发现一些奇怪的事情发生了,我不明白为什么?在

所以当我从“开始”菜单启动powershell并键入命令python,python就会启动。当我在桌面位置启动powershell时(shift+右键单击->打开powershell),仍然可以访问python命令(如下图所示)。 python accessible in the powershell started in desktop location 但是,当我在任何其他位置(比如e:/python/playground)启动powershell时,使用windows资源管理器导航到它,然后从shift+right-click菜单运行powershell,则无法访问python命令。 python inaccessible in powershell started in a specific location 但是如果我从开始菜单启动powershell,然后cd到同一个位置,那么python命令就可以访问了。 python accessible when powershell started from startmenu and navigated to particular location 为什么对于启动powershell的不同方式,python我会看到不同的行为?它让我想到,如果有一个不同的环境设置为壳牌?在


Tags: 命令键入shift方式菜单环境变量事情桌面