我可以仅使用诗歌安装新版本的Python吗?
免责声明
我是诗歌
新手
- 的 不在乎我如何指定它,但大概是在
pyproject.toml
中) - 运行命令(大概是
poetry shell
或诗歌>诗歌安装
,也许在与诗歌env使用
)的结合,使我进入了我已经指定的python版本的环境(我不介意它是几个命令,而不是仅一个命令)
:
- <代码>诗歌env使用3.10 (当我还没有安装python 3.10时)
- 这给了我一个错误:
/bin/sh:python3.10:找不到命令
- 值得注意的是,我明白了为什么出现此错误,我只是想拥有
Poetry
在这种情况下安装Python 3.10
- 这给了我一个错误:
诗歌env使用3.10
(当我在conda
Env中,已安装了Python 3.10)- 这有效!但是...
python
可执行与conda env 中的一个相称 - 也许这很好,但是我的目标是使用
诗歌
而不是conda
,所以我想避免依靠conda
安装Python版本
- 这有效!但是...
我看到的人所做的是:
使用诗歌
与pyenv (其中
pyenv
用于安装Python版本)。
因此,我的问题是:
是否使用pyenv
来安装必要的python版本?是否没有办法告诉诗歌
我想要 it 安装给定的Python版本?
我已经浏览了诗歌
文档,他们的GH问题以及一些帖子,但是(如果我缺少某些内容,请再次表示歉意。
附加信息
诗歌
版本:1.1.13- OS:MacOS(Catalina)
- Python版本用于安装
Poetry
(因此,它似乎默认为):3.7.6 - Happy添加其他相关内容:)
Disclaimer
I'm new to poetry
and I've searched around, but apologies if I've missed something obvious..
What I want to do is:
- specify an arbitrary python version in a poetry project (I don't care how I specify it, but presumably in
pyproject.toml
) - run a command (presumably
poetry shell
orpoetry install
, maybe in conjunction withpoetry env use
) that puts me into an environment that uses the python version I specified above (I don't mind if it's a few commands instead of just one)
I've already tried:
poetry env use 3.10
(when I don't have python 3.10 installed already)- This gives me an error:
/bin/sh: python3.10: command not found
- Notably, I get why this error is showing up, I'd just like to have
poetry
install python 3.10 in this case
- This gives me an error:
poetry env use 3.10
(when I'm in aconda
env that has python 3.10 installed)- This works! But... the
python
executeable is symlinked to the one in the conda env - Maybe this is fine, but my goal is to use
poetry
instead ofconda
so I'd like to avoid relying onconda
to install python versions
- This works! But... the
What I've seen people do is:
Use poetry
in conjunction with pyenv
(where pyenv
is used to install the python version).
So, my question is:
Is using something like pyenv
to install python versions necessary? Is there no way to tell poetry
that I want it to install a given python version?
I've looked through the poetry
docs, their GH issues, and some SO posts, but (again) apologies if I'm missing something.
Additional Info
poetry
version: 1.1.13- OS: MacOS (Catalina)
- python version used to install
poetry
(and therefore the one it seems to default to): 3.7.6 - happy to add anything else relevant :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Poetry不能也不会为你安装任何python解释器。这超出了范围。用户有责任提供一份。
pyenv 是一种方法。
Poetry cannot and will not install any python interpreter for you. This is out of scope. It's the responsibility of the user to provide one.
pyenv
is one way of doing it.