PowerShell中Poetry提示‘No Python at "D:\python.exe’如何修复?
解决Poetry提示找不到Python路径的问题
一、手动指定Poetry关联的Python环境
- 先确认当前Python的实际路径,在PowerShell中执行:
会输出你当前可用的Python安装路径(比如where pythonC:\Users\你的用户名\AppData\Local\Programs\Python\Python312\python.exe) - 让Poetry使用这个路径的Python,执行:
示例:poetry env use 你的Python实际路径poetry env use C:\Users\Owen\AppData\Local\Programs\Python\Python312\python.exe - 验证是否修复:执行
poetry --version
二、卸载重装Poetry重置环境
如果上面的方法无效,完全可以卸载后重装Poetry:
- 卸载Poetry,在PowerShell中执行:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - --uninstall - 重装Poetry,执行:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - - 重装完成后,再次执行
poetry --version,Poetry会自动关联当前可用的Python
三、额外检查项
- 确认Python已添加到系统环境变量:执行
echo $env:PATH,查看输出中是否包含Python的安装目录和其下的Scripts子目录 - 若修改环境变量后仍有问题,重启PowerShell再尝试
内容的提问来源于stack exchange,提问作者Owen Wu
相关产品推荐
相关产品推荐

