question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

poetry creates virtualenv with newer python rather than using existing env

See original GitHub issue

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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
MattiooFRcommented, Apr 12, 2020

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…

1reaction
finswimmercommented, Apr 10, 2020

Hello again,

poetry expects in first place that the venv uses the same python version as the to whatever the python binary links to. Beside the way I explained above, another solution is to set virtualenvs.in-project to true. This will create the venv within you project folder and poetry will recognize it at first place.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found