欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 高考 > Windows11 安装poetry

Windows11 安装poetry

2025/6/28 22:53:54 来源:https://blog.csdn.net/weixin_44810982/article/details/145394801  浏览:    关键词:Windows11 安装poetry

使用powershell安装


(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -

如果使用py运行失败则替换为python即可

终端运行结果如下

D:\AI\A_Share_investment_Agent> (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
Retrieving Poetry metadata# Welcome to Poetry!This will download and install the latest version of Poetry,
a dependency and package manager for Python.It will add the `poetry` command to Poetry's bin directory, located at:C:\Users\phoenix\AppData\Roaming\Python\ScriptsYou can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.Installing Poetry (2.0.1)
Installing Poetry (2.0.1): Creating environment
Installing Poetry (2.0.1): Installing Poetry
Installing Poetry (2.0.1): Creating script
Installing Poetry (2.0.1): DonePoetry (2.0.1) is installed now. Great!To get started you need Poetry's bin directory (C:\Users\phoenix\AppData\Roaming\Python\Scripts) in your `PATH`
environment variable.You can choose and execute one of the following commands in PowerShell:A. Append the bin directory to your user environment variable `PATH`:```
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";C:\Users\phoenix\AppData\Roaming\Python\Scripts", "User")
```B. Try to append the bin directory to PATH every when you run PowerShell (>=6 recommended):```
echo 'if (-not (Get-Command poetry -ErrorAction Ignore)) { $env:Path += ";C:\Users\phoenix\AppData\Roaming\Python\Scripts" }' | Out-File -Append $PROFILE
```Alternatively, you can call Poetry explicitly with `C:\Users\phoenix\AppData\Roaming\Python\Scripts\poetry`.You can test that everything is set up by executing:`poetry --version`

此时如果运行poetry --version

D:\AI\A_Share_investment_Agent> poetry --version
poetry : 无法将“poetry”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径
正确,然后再试一次。
所在位置 行:1 字符: 1
+ poetry --version
+ ~~~~~~+ CategoryInfo          : ObjectNotFound: (poetry:String) [], CommandNotFoundException+ FullyQualifiedErrorId : CommandNotFoundException

可以发现并没有成功安装,这是因为我们没有添加到环境变量

配置环境变量

1. 在用户变量Path中添加%APPDATA%\Python\Scripts

2. 在系统变量中添加 

检验是否配置成功 

C:\Users\phoenix>poetry --version
Poetry (version 2.0.1)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词