Poetry doesn't use my own virtual environment #7767
Replies: 10 comments 16 replies
-
Do not install poetry into the same env as your project. |
Beta Was this translation helpful? Give feedback.
-
Poetry creates he's own virtual environment, then he doesn't install anything in your virtual environment... |
Beta Was this translation helpful? Give feedback.
-
Why do you want to nest the environments? Also, you can disable this behavior so that
|
Beta Was this translation helpful? Give feedback.
-
Did you ever find a fix for this? All of a sudden, I've ran into some venv issues and have created a new one, but now poetry refuses to detect it and keeps creating new ones evertime I attempt to start my project. |
Beta Was this translation helpful? Give feedback.
-
If you don't want to use the virtual environment created by Poetry and want to use your own virtual environment, you can run the following command to install the dependencies in your own virtual environment: poetry install --no-root This will install the dependencies in a virtual environment created by you, and you can activate it using the source /path/to/your/virtual/environment/bin/activate |
Beta Was this translation helpful? Give feedback.
-
TLDR: try naming your venv I'm on poetry 1.8.2. I'm not sure if this has changed since this original post, but the docs seem to indicate the venv should be named
The following steps worked for me: poetry config virtualenvs.create false --local
python3 -m venv .venv
poetry install |
Beta Was this translation helpful? Give feedback.
-
Use this config after install
Basically this will say to poetry don't create a venv and will preffer your active python, in this case, the python from venv. You can see all poetry config calling
|
Beta Was this translation helpful? Give feedback.
-
It is likely that VS Code is the culprit for you. If you have set your python interpreter to another project it may refuse to change the ENV as the python version that gets executed will always point to that other project in terminal even if you specify the path manually to In my instance I had to bump out to the main ubuntu instance where From there I could Also, verify that you're saving your env to PITA... |
Beta Was this translation helpful? Give feedback.
-
what worked for me:
|
Beta Was this translation helpful? Give feedback.
-
For anyone that has the same problem, please check if you don't have conda activated. I had a short brush with conda environment and forgot to deactivate it, assuming that activation is short lived and for the current terminal session only. Check if Since the EnvManager.get checks it as well beside plain virtual environment, the check below failed to use poetry/src/poetry/utils/env/env_manager.py Line 224 in 341071a |
Beta Was this translation helpful? Give feedback.
-
I'd like to create a project with poetry. Here's my workflow (all done inside a folder in which I have a pyproject.toml file defined):
However, it seems that poetry installs all dependencies defined in the pyproject.toml not in the "env" virtual environment but in its own virtual environment. The package in my case is called "fondant", and when wanting to run it I get:
Also, neither of all dependencies of fondant (defined in the pyproject.toml file) are present in the virtual environment.
On the website is stated that:
Shouldn't it automatically recognize the virtual environment and install packages there?
I'm running everything in VSCode, on a Macbook Pro with MacOS Monterey 12.5.1.
Any help is appreciated!
Update:
when activating the virtual environment that Poetry created by itself by running
poetry shell
, I can import the packages and see all installed dependencies being installed there:But this is not really in line with what is stated on the website.
Beta Was this translation helpful? Give feedback.
All reactions