poetry命令:
poetry init 将项目初始化变成poetry管理的项目
poetry new myproject(如果从其他地方拿来的项目不是poetry环境,首先用poetry init命令将项目初始化变成poetry管理的项目)
poetry add pakage 添加包
poetry install 添加所有依赖
poetry shell 进入环境中,可以用pip安装,比如langgraph用poetry安装会报错,但用pip安装可以。使用poetry shell前需要安装插件:poetry self add poetry-plugin-shell
poetry env use 3.12 使用python3.12的解释器
poetry python install 3.12 安装python3.12的解释器
poetry source add ali https://mirrors.aliyun.com/pypi/simple/ 添加镜像源
也可以在pyproject.toml下添加如下代码:
[[tool.poetry.source]]
name = "ali"
url = "https://mirrors.aliyun.com/pypi/simple/"
priority = "primary"
[[tool.poetry.source]]
name = "tencent"
url = "https://mirrors.cloud.tencent.com/pypi/simple/"
priority = "primary"
[[tool.poetry.source]]
name = "tsinghua"
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/"
priority = "default"