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.

Option to force Poetry to create a virtual environment, even if a virtual env is active

See original GitHub issue

I am using Poetry from within a conda environment; with Poetry being installed by conda (poetry is present in the environment.yaml file). This might not be ideal but for a specific setup this seems to work well.

When running poetry install, a venv is not created because Poetry detect that a virtual environment (the Conda one) is already active.

I believe that we should be able to force Poetry to create a virtual environment anyway: the Conda environment is more “physical” than virtual in this case, as it replaces the system Python.

The same issue occurs when doing poetry shell from within the Conda environment, after creating the virtual environment with the following workaround: I deactivate the Conda environment, use the full path to Poetry (in the bin directory of the Conda environment) and do poetry install.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:25
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
jaklancommented, Aug 8, 2022

+1 for the conda case, it’s pretty problematic in our remote environment, where python interpreter is provided by conda and poetry install doesn’t create project-specific venvs…

2reactions
mforbescommented, Jul 20, 2021

One other feature that would be really nice is if poetry shell could activate whatever environment is needed, including calling conda activate. I am not sure how internally this works, but the following workflow would be very useful:

conda activate my_conda_env
poetry env use python        # Tell poetry to use the my_conda_env
poetry shell                 # This works.

After doing this, it would be very nice if this or something similar could store information about the choice of environment in poetry.toml or something so that running poetry shell from within the project first activates the my_conda_env (until poetry env use or similar is called in the future).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing environments | Documentation
To achieve this, it will first check if it's currently running inside a virtual environment. If it is, it will use it directly...
Read more >
poetry Virtual environment already activated - python
I'd have to do the following source "$( poetry env list --full-path | grep Activated | cut -d' ' -f1 )/bin/activate".
Read more >
Python Virtual Environments tutorial using Virtualenv and ...
A mini-guided Python tutorial showing how to use virtual environment and why it's matters on virtualenv and poetry illustrated examples.
Read more >
Python Virtual Environments: A Primer
In this tutorial, you'll learn how to work with Python's venv module to create and manage separate virtual environments for your Python ...
Read more >
Virtual Environments — mod_wsgi 4.9.4 documentation
The purpose of a Python virtual environments is to allow one to create ... environment to force mod_wsgi to use a different Python...
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