-1

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?

  • 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 Answers2

0
  1. Use pyenv to manage multiple Python installations in your system.
  2. Set virtualenvs.prefer-active-python to true in the Poetry config
  3. Change you current python via pyenv shell X.y.z before running poetry 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