遇事不会看官网

Introduction | Documentation | Poetry - Python dependency management and packaging made easy

 前言官网提供了四种安装方式

由于pipx容易出问题这里选择了powerShell直装

1.win+R,输入powershell,调出工具

2.自定义poetry的安装位置,在目标位置建Poetry文件夹,在命令行中指令输入预装位置,此处为F:\Poetry,执行此操作poetry才会安装在自定义目录,否则默认安在

  • %APPDATA%\pypoetry on Windows.

  

 $env:POETRY_HOME = "F:\Poetry"

3.安装poetry,此时需要已经安装了python,并与poetry的最新版本相匹配,如果需要安旧版本需要带上版本号,否则会报错,在日志中可以看到match不到某一版本的python,安装那个版本

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

 中途报错日志,版本不匹配

ERROR: Ignored the following versions that require a different python version: 1.6.0 Requires-Python >=3.8,<4.0; 1.6.1 Requires-Python >=3.8,<4.0; 1.7.0 Requires-Python >=3.8,<4.0; 1.7.1 Requires-Python >=3.8,<4.0; 1.8.0 Requires-Python >=3.8,<4.0; 1.8.1 Requires-Python >=3.8,<4.0; 1.8.2 Requires-Python >=3.8,<4.0; 1.8.3 Requires-Python <4.0,>=3.8; 1.8.4 Requires-Python <4.0,>=3.8; 1.8.5 Requires-Python <4.0,>=3.8; 2.0.0 Requires-Python <4.0,>=3.9; 2.0.1 Requires-Python <4.0,>=3.9; 2.1.0 Requires-Python <4.0,>=3.9; 2.1.1 Requires-Python <4.0,>=3.9
ERROR: Could not find a version that satisfies the requirement poetry==2.1.1 (from versions: 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.4.0.post1, 0.4.1, 0.4.2, 0.5.0b1, 0.5.0b2, 0.5.0, 0.6.0, 0.6.1, 0.6.2, 0.6.3b1, 0.6.3b2, 0.6.3b3, 0.6.3b4, 0.6.3b5, 0.6.3b6, 0.6.3b7, 0.6.3, 0.6.4b1, 0.6.4, 0.6.5, 0.7.0b1, 0.7.0b2, 0.7.0b3, 0.7.0b4, 0.7.0, 0.7.1, 0.8.0a0, 0.8.0a1, 0.8.0a2, 0.8.0a3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台电脑上装不同版本pythonwindows装多版本python-CSDN博客 

 4.下载成功配置环境变量,下载成功会有提示,跟据提示选择永久配置环境变量(A),或者每次运行poetry命令前配置(b)复制引号内容

这里永久添加

[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";D:\Poetry\bin", "User")

5.检查命令,重新打开cmd

poetry --version

6.使用

 poetry使用-CSDN博客

更多推荐