I have to work on two projects, one with a version of Python 3.7 and the other with 3.10, but every time I need to switch from one to another I have to reinstall poetry. Any idea, to avoid reinstall poetry?
What is the best practices to have multiple poetry versions with different python versions in linux?
Asked
Active
Viewed 40 times
-1
-
I'm not very familiar with `poetry` but my gut tells me that `anaconda` would be a good fit to manage the overall environment. [This answer](https://stackoverflow.com/questions/70851048/does-it-make-sense-to-use-conda-poetry) suggests that it may be a reasonable way of setting up your environment(s). – JNevill Aug 28 '23 at 13:21
-
Personally, I do this with [Nix](https://nixos.org/), which can itself not just install different versions of Python or Poetry but _anything else you want_; different versions of node.js, different versions of openssl, etc etc etc. – Charles Duffy Aug 28 '23 at 15:24
-
I found this link useful: https://github.com/orgs/python-poetry/discussions/7866 – Juan Fernando Jaramillo Botero Aug 28 '23 at 15:48
2 Answers
0
- Use pyenv to manage multiple Python installations in your system.
- Set virtualenvs.prefer-active-python to
true
in the Poetry config - Change you current python via
pyenv shell X.y.z
before runningpoetry install
the first time.
Alternatively you can run poetry env use /path/to/python
once before running any other Poetry command on your project.
There is no need to have multiple Poetry version for different Python versions.
See also: https://python-poetry.org/docs/managing-environments/

finswimmer
- 10,896
- 3
- 34
- 44
0
You can contextualize pip per version of python.
Like :
python3.4 -m pip install poetry==1.2.1
python3.7 -m pip install poetry==2.4.6

Loïc
- 11,804
- 1
- 31
- 49