poetry creates virtualenv with newer python rather than using existing env
See original GitHub issue-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
OS version and name: macOS
-
Poetry version: 1.0.5
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/cjw296/c60c14f105b24f3ca625a11c87789fa6
Issue
I’ve seen this across linux and mac, steps roughly as follows:
- my project has
python = "^3.7"
- I run poetry shell which creates a virtualenv,
ansible-config--DcQW89x-py3.7/
in this case. - I do lots of setup, installation, use the env, months pass…
- I install a new version of Python on the machine (3.8 in this case)
- The next time I run poetry shell, rather than using the existing env, it creates a new, empty one,
ansible-config--DcQW89x-py3.8/
.
This should not happen, the existing environment should be used.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Managing environments | Documentation - Poetry
If you use a tool like pyenv to manage different Python versions, you can set the experimental virtualenvs.prefer-active-python option to true .
Read more >Python Virtual Environments tutorial using Virtualenv and Poetry
A mini-guided Python tutorial showing how to use virtual environment and why it's matters on virtualenv and poetry illustrated examples.
Read more >How to create a brand new virtual environment or duplicate an ...
Poetry seems to be bound to one virtualenv per python interpreter. Poetry is also bound to the pyproject.toml file and its path to...
Read more >Python Poetry: Package and venv Management Made Easy
Learn how to install and use the Python Poetry package manager to manage the dependencies and virtual environment(s) of your Python project.
Read more >Poetry vs Virtualenv for Managing Dependencies in Python ...
Poetry isolates the virtualenv from the project. It automatically creates an env at the .cache folder in the $HOME directory.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I actually have the same problem, but without changing my version of python. I don’t know why but it seems randomly poetry will forget the path of the previously created venv and will create a new empty one, quite annoying…
Hello again,
poetry
expects in first place that the venv uses the same python version as the to whatever thepython
binary links to. Beside the way I explained above, another solution is to setvirtualenvs.in-project
totrue
. This will create the venv within you project folder and poetry will recognize it at first place.