Closed 2269881521 closed 1 year ago
这个情况恰恰说明你系统里的Python环境存在某些潜在问题,以后可能带来很多麻烦,借此机会彻底理清为上。
在PowerShell命令行中一条一条地执行下面的命令,把每一条的结果贴上来:
Get-Command python
Get-Command python3
Get-Command pip
Get-Command pip3
python -V
python3 -V
pip -V
pip3 -V
`PS C:\Users\86173\Code> Get-Command python
CommandType Name Version Source
Application python.exe 0.0.0.0 C:\Users\86173\AppData\Local\Microsoft\WindowsApps\python.exe
PS C:\Users\86173\Code> Get-Command python3
CommandType Name Version Source
Application python3.exe 0.0.0.0 C:\Users\86173\AppData\Local\Microsoft\WindowsApps\python3.exe
PS C:\Users\86173\Code> Get-Command pip
CommandType Name Version Source
Application pip.exe 0.0.0.0 C:\Users\86173\AppData\Local\Programs\Python\Python312\Scripts\pip.exe
PS C:\Users\86173\Code> Get-Command pip3
CommandType Name Version Source
Application pip3.exe 0.0.0.0 C:\Users\86173\AppData\Local\Programs\Python\Python312\Scripts\pip3.exe
PS C:\Users\86173\Code> python -V PS C:\Users\86173\Code> python3 -V PS C:\Users\86173\Code> pip -V pip 23.3 from C:\Users\86173\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip (python 3.12) PS C:\Users\86173\Code> pip3 -V pip 23.3 from C:\Users\86173\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip (python 3.12)`
PS C:\Users\86173\Code> python -V PS C:\Users\86173\Code> python3 -V
在执行上述两条指令时会报错
前面的输出结果,显示在PowerShell命令行里找不到你安装的Python,这是很大的隐患,建议检查系统PATH变量的设置,必要时重装Python包。
在PowerShell的命令行中运行python test.py的命令,会出现以下报错 但是点击右上方的运行代码,则是可以正常运行的