pyenv: poetry itself, running on older python version, what to do?
Question:
Update:
Which Python should I use to install poetry?
- System Python: That is an excellent idea. Once, however,
poetry self update
was trying to update a system package without the necessary permissions.
- Pyenv: A good solution. Nonetheless, if Python is updated and the old installation is deleted, poetry will stop working because it is not aware of the new python version.
- Set global python with pyenv
pyenv global 3.10.7
- Install poetry
$ curl -sSL https://install.python-poetry.org | python3 -
- Change global python
pyenv global 3.10.8
Now, poetry
still runs on Python-3.10.7
. If I uninstall this python version, poetry crashes.
How can I instruct the virtual environment of poetry to use the new python version?
A solution is to uninstall and reinstall it:
$ curl -sSL https://install.python-poetry.org | python3 - --uninstall
$ curl -sSL https://install.python-poetry.org | python3 -
Is there any other way?
Answers:
By default Poetry will use the Python version used during it installation to create a new venv.
Set the (experimental) config option virtualenvs.prefer-active-python to true
, if you want Poetry to pick up the current activated Python version.
As an alternative to this option, run poetry env use </path/to/python>
once before any other Poetry command, to set the python interpreter that should be used. See https://python-poetry.org/docs/managing-environments/#switching-between-environments
The decision is to use Pyenv to install Poetry.
If the older python version should be deleted:
- Uninstall Poetry.
- Delete old Python version.
- Install Poetry.
Update:
Which Python should I use to install poetry?
- System Python: That is an excellent idea. Once, however,
poetry self update
was trying to update a system package without the necessary permissions. - Pyenv: A good solution. Nonetheless, if Python is updated and the old installation is deleted, poetry will stop working because it is not aware of the new python version.
- Set global python with pyenv
pyenv global 3.10.7
- Install poetry
$ curl -sSL https://install.python-poetry.org | python3 -
- Change global python
pyenv global 3.10.8
Now, poetry
still runs on Python-3.10.7
. If I uninstall this python version, poetry crashes.
How can I instruct the virtual environment of poetry to use the new python version?
A solution is to uninstall and reinstall it:
$ curl -sSL https://install.python-poetry.org | python3 - --uninstall
$ curl -sSL https://install.python-poetry.org | python3 -
Is there any other way?
By default Poetry will use the Python version used during it installation to create a new venv.
Set the (experimental) config option virtualenvs.prefer-active-python to true
, if you want Poetry to pick up the current activated Python version.
As an alternative to this option, run poetry env use </path/to/python>
once before any other Poetry command, to set the python interpreter that should be used. See https://python-poetry.org/docs/managing-environments/#switching-between-environments
The decision is to use Pyenv to install Poetry.
If the older python version should be deleted:
- Uninstall Poetry.
- Delete old Python version.
- Install Poetry.