-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poetry fails to use the currently activated environnement #8631
Comments
poetry just looks at environment variables to find the current virtual environment, I don't see anything special about hyphens poetry/src/poetry/utils/env/env_manager.py Lines 252 to 256 in f004a70
so you should start there to understand what's actually happening |
yeah, does not reproduce. I'm starting with this docker file: # syntax=docker/dockerfile:1.5
FROM continuumio/miniconda3:23.9.0-0
RUN apt-get update && \
apt-get install \
--yes \
--no-install-recommends \
curl && \
curl \
--silent \
--show-error \
--location \
--output install-poetry.py \
https://install.python-poetry.org && \
python3 install-poetry.py
ENV PATH="/root/.local/bin:$PATH" Then the sequence of commands that you give ends with: (poetry-project) root@16b75389eb12:/poetry-project# poetry env info
Virtualenv
Python: 3.11.5
Implementation: CPython
Path: /opt/conda/envs/poetry-project
Executable: /opt/conda/envs/poetry-project/bin/python
Valid: True
System
Platform: linux
OS: posix
Python: 3.11.5
Path: /opt/conda/envs/poetry-project
Executable: /opt/conda/envs/poetry-project/bin/python3.11 please provide a way to reproduce - or close |
Indeed, I'm not able to reproduce the issue reliably neither. I guess its an interference with other tools I use locally (pyenv, conda, etc.). |
@dimbleby It happened again on another machine so I took the time to debug this. I think I now have a reproducible example (the issue is not related to hyphens): poetry new project
cd project
poetry env use 3.11 # Assuming 3.11 is available and supported
poetry env remove --all
conda env create -n project python=3.11 -y
conda activate project
poetry env info This results in the same issue as mentioned in my first post, i.e. the conda environment is not detected:
After debugging a little, it looks like the command Then, when getting an environment, the poetry/src/poetry/utils/env/env_manager.py Lines 246 to 250 in f004a70
I believe that here the The error does not occur removing the virtual environment explicitly (without |
sounds like you must be about ready to submit a fix...? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Poetry version: 1.7.0
Python version: 3.11
OS version and name: Ubuntu 22.04.3 LTS
pyproject.toml: Empty TOML as created by
poetry new <project>
I am on the latest stable Poetry version, installed using a recommended method.
I have searched the issues of this repo and believe that this is not a duplicate.
I have consulted the FAQ and blog for any relevant entries or release notes.
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option) and have included the output below.Issue
In some circonstances Poetry fails to use the activated virtual environnement (for instance a Conda environnement). In my experiments, this seems to occur when there is an hyphen (
-
) in the name of the folder of the project (for instancepoetry-project
).To Reproduce
poetry new poetry-project cd poetry-project conda create -n poetry-project python=3.11 -y conda activate poetry-project poetry env info
This returns:
This works correctly if I change the folder name to use an underscore(
_
) instead of the hyphen (-
), for instancepoetry_project
.The text was updated successfully, but these errors were encountered: