侧边栏壁纸
  • 累计撰写 74 篇文章
  • 累计创建 41 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

Python poetry 虚拟环境位置和换源

勤为径苦作舟
2023-11-27 / 0 评论 / 0 点赞 / 142 阅读 / 1741 字 / 正在检测是否收录...

简介

Poetry 是 Python 的项目依赖管理构建打包工具。

官网:Poetry - Python dependency management and packaging made easy
源码:GitHub - python-poetry/poetry: Python packaging and dependency management made easy

安装并修改虚拟环境路径

# 使用 pipx 安装 poetry
$ pipx install poetry

# poetry 修改虚拟环境路径
$ poetry config cache-dir D:\Cache\pypoetry

# 查看 poetry 配置
$ poetry config --list
cache-dir = "D:\\Cache\\pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # D:\Cache\pypoetry\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

创建项目并修改镜像源

# poetry 创建项目
$ poetry new poetrytest
$ cd poetrytest

# 设置默认镜像
$ poetry source add --priority=default mirrors https://pypi.tuna.tsinghua.edu.cn/simple/

# 进入虚拟环境
$ poetry shell
Spawning shell within D:\Cache\pypoetry\virtualenvs\poetrytest-GGuV2pTH-py3.10

(poetrytest-py3.10) C:\Users\Administrator\Desktop\poetrytest>

参考

0

评论区