You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用py launcher管理多Python版本时,Poetry shell插件无法在Python 3.12环境中生效的问题及方案咨询

使用py launcher管理多Python版本时,Poetry shell插件无法在Python 3.12环境中生效的问题及方案咨询

我最近在Windows上用官方Python做项目时遇到了个头疼的问题,想请教大家有没有可行的解决办法,或者更合理的多Python版本+Poetry管理方案。具体情况如下:

项目与工具需求

我要做的项目依赖一个仅支持Python的包,而且因为兼容性问题必须用Python 3.12.x(部分依赖包还不兼容3.13.x)。为了避免全局安装包导致的版本冲突,我选择用poetry做项目管理,让每个项目的依赖只在本地生效。

当前环境配置

  • 系统:Windows,没使用Anaconda,完全依赖python.org的官方安装包
  • 已安装Python版本:3.13.1和3.12.8,都没加入系统PATH,全程用官方自带的py launcher来切换版本
  • 两个Python版本都通过pip安装了poetry

遇到的插件问题

因为Poetry 2.x的核心功能里移除了shell命令,我通过py -m poetry self add poetry-plugin-shell给默认的Python 3.13安装了shell插件。之后我想给Python 3.12也装上这个插件,执行命令时却得到提示说插件已经存在:

Z:\project_name>py -3.12 -m poetry self add poetry-plugin-shell
The following packages are already present in the pyproject.toml and will be skipped:

  - poetry-plugin-shell

If you want to update it to the latest compatible version, you can use `poetry self update`.
If you prefer to upgrade it to the latest available version, you can use `poetry self add package@latest`.

Nothing to add.

但实际使用时,py -3.12 -m poetry shell却提示命令不存在:

Z:\project_name> py -3.12 -m poetry shell

The command "shell" does not exist.

而且查看3.12环境下的Poetry插件列表,结果是空的:

Z:\project_name>py -3.12 -m poetry self show plugins

Z:\project_name>

我的疑惑与求助方向

我注意到%APPDATA%\pypoetry这个目录是不针对特定Python版本的,所以怀疑Poetry和py launcher之间可能存在兼容性问题?现在我有点不确定自己这种用py launcher管理多版本、配合Poetry做项目隔离的思路是不是本身就有问题,想问问大家:

  • 有没有办法让Poetry的shell插件在Python 3.12环境下正常生效?
  • 对于Windows上同时管理多个Python版本、且不同项目依赖不同Python版本的场景,有没有更稳妥的工具搭配或使用方案?

备注:内容来源于stack exchange,提问作者chsk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 13:24:29