Skip to content
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 seems to ignore virtualenvs.create #4187

Closed
3 tasks done
mchccc opened this issue Jun 17, 2021 · 18 comments · Fixed by #4406
Closed
3 tasks done

poetry seems to ignore virtualenvs.create #4187

mchccc opened this issue Jun 17, 2021 · 18 comments · Fixed by #4406
Labels
kind/bug Something isn't working as expected

Comments

@mchccc
Copy link

mchccc commented Jun 17, 2021

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Debian GNU/Linux 10 (Docker python:3.6)
  • Poetry version: 1.1.6
  • Link of a Gist with the contents of your pyproject.toml file: gist link

Issue

I recently recreated my Docker images, and replaced the old get-poetry.py with install-poetry.py, and suddenly my entry command was not working anymore, failing with ModuleNotFoundError.

My poetry install invocations correctly output Skipping virtualenv creation, as specified in config file., which is what I asked via poetry config virtualenvs.create false, but by looking around I found them being placed in the POETRY_HOME/venv folder, and therefore not being found by my simple python -m entrypoint:

root@71978f3d0878:/code/src# ls /opt/poetry/venv/lib/python3.6/site-packages/
Babel-2.9.1.dist-info			       blackd				factory_boy-2.12.0.dist-info	     lockfile			      pyOpenSSL-20.0.1.dist-info	 shellingham-1.4.0.dist-info
CacheControl-0.12.6.dist-info		       blib2to3				faker				     lockfile-0.12.2.dist-info	      pyasn1				 six-1.16.0.dist-info

Am I doing something wrong, or did something break with some of the updates I skipped?

Thanks

@mchccc mchccc added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 17, 2021
@mchccc
Copy link
Author

mchccc commented Jun 18, 2021

I reverted the install script to get-poetry.py and it works again

root@4e2f6d2ab52f:/code/src# ls -lhart /opt/poetry/env 
-rw-r--r-- 1 root root 35 Jun 18 10:16 /opt/poetry/env
root@4e2f6d2ab52f:/code/src# python -c "import sys, pprint; pprint.pprint(sys.path)"
['',
 '/usr/local/lib/python36.zip',
 '/usr/local/lib/python3.6',
 '/usr/local/lib/python3.6/lib-dynload',
 '/root/.local/lib/python3.6/site-packages',
 '/usr/local/lib/python3.6/site-packages',
 '/dependencies']
root@4e2f6d2ab52f:/code/src# ls /usr/local/lib/python3.6/site-packages
Babel-2.9.1.dist-info			       autopep8.py			elasticsearch-6.3.1.dist-info	    jmespath			     pycodestyle-2.7.0.dist-info	six.py
Cryptodome				       babel				elasticsearch5			    jmespath-0.10.0.dist-info	     pycodestyle.py			snowballstemmer
Cython					       black				factory				    lxml			     pycparser				snowballstemmer-2.1.0.dist-info

@finswimmer
Copy link
Member

Hello @cicuz,

the new installer script install-poetry.py (which I would only recommend for installing poetry >=1.2.0 and its prereleases) isolate the poetry installation in its own venv. The get-poetry.py vendors the dependencies instead and poetry will use the currently activated python executable when running.

The downside of the isolation of poetry running in its own venv is, that it is hard to find out which python is currently activated in the shell and therefore where the global place for installing packages is.

I've already start talking about this topic with @sdispater .

fin swimmer

@mchccc
Copy link
Author

mchccc commented Jun 18, 2021

Hello fin, thanks for getting back to me!

I'm not sure I understand all the implications of the issues you're rising though; is the discussion you mentioned a public one?

@finswimmer
Copy link
Member

is the discussion you mentioned a public one?

At the moment this is just a private discussion on our discord server. But you can join the public channel if you like to discuss there.

@sdispater
Copy link
Member

@cicuz Your use case should be fixed by #4192.

Could you try by installing Poetry from the 1.1 branch?

python install-poetry.py --git https://github.com/python-poetry/poetry.git@1.1

@finswimmer finswimmer added the status/waiting-on-response Waiting on response from author label Jul 4, 2021
@mchccc
Copy link
Author

mchccc commented Jul 5, 2021

It seems to be behaving the same way, i.e. still ignoring the "not create virtualenv" directive. This is the code I used

RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py --output install-poetry.py && \
    python install-poetry.py --git https://github.com/python-poetry/poetry.git@1.1 && \
    poetry config virtualenvs.create false && \
    cd /dependencies && \
    poetry install

@max-wittig
Copy link

We encountered the same issue with the new installer script.

@dlouzan @ercanucan

@max-wittig
Copy link

@sandpipersburg We don't use pyenv in the container, so I think that this is a different issue. Could you delete the comment and create a separate one to not pollute this one?

@jian-robo
Copy link

@sandpipersburg We don't use pyenv in the container, so I think that this is a different issue. Could you delete the comment and create a separate one to not pollute this one?

Done: Poetry stuck at pyenv Python version active during install-poetry, broken after version uninstall #4317

@thiras
Copy link

thiras commented Jul 30, 2021

I confirm the bug

@TheGreatRefrigerator
Copy link

I still encounter this problem with the latest 1.2.0a2 release, which should contain the fix?
OS of the Docker image Debian GNU/Linux 10 \n \l

FROM tiangolo/uvicorn-gunicorn:python3.8

# get DEV argument from docker-compose file
ARG DEV

# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | POETRY_HOME=/opt/poetry python - --preview && \
    cd /usr/local/bin && \
    ln -s /opt/poetry/bin/poetry && \
    poetry config virtualenvs.create false

COPY ./pyproject.toml ./poetry.lock* /app/

RUN if [ "$DEV" = "1" ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi

when doing poetry install, poetry says that it skips virtual env creation (as defined by the config), but still installs all packages to $POETRY_HOME/venv/lib and not to /usr/local/lib/python3.8/site-packages which is used by the system python interpreter and where it is installed when using the get-poetry.py script.

running python from anywhere else than in $POETRY_HOME/venv/lib/python3.8/site-packages/
will not let me import the installed dependencies specified in pyproject.toml.

@sdispater
Copy link
Member

@TheGreatRefrigerator Could you test if the master branch fixes the issue?

@TheGreatRefrigerator
Copy link

@sdispater Yes, version 1.1.8 fixes the issue, thanks.
Will this be included in 1.2 at some point as well?

TheGreatRefrigerator added a commit to GIScience/heigit-disaster-portal that referenced this issue Feb 24, 2022
get-poetry.py is deprecated and will be removed in the future.
Currently update to poetry 1.2 is still not possible.
See python-poetry/poetry#4187

Closes https://gitlab.gistools.geog.uni-heidelberg.de/giscience/heigit-disaster-portal/-/issues/20
@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
@mkniewallner mkniewallner removed the status/waiting-on-response Waiting on response from author label Jun 11, 2022
@varneyo
Copy link

varneyo commented Sep 9, 2022

@TheGreatRefrigerator @sdispater I am using the same tiangolo codebase / project / dockerfile and have wasted a fair amount of time trying to fix this / trying to understand. Can someone provide instructions or ideally @TheGreatRefrigerator an updated docker file. Apologies Ive tried everything now and I feel like I need explaining to me like im a 5 year old to get it to work. I can see virtualenvs.create is being ignored and that site packages are ending up in /usr/lib/python3.9/site-packages which is not in my PATH.

@TheGreatRefrigerator
Copy link

@varneyo just follow the linked commit above. In that repo the setup is working. Although i think poetry switched to a different location for the install script already, which is not yet reflected.

@iSplasher
Copy link

iSplasher commented Feb 8, 2023

This is still an issue with Poetry (version 1.3.2)
I tried 1.1.15 (the latest 1.1.x) and it didn't work.
Only 1.1.8 seems to work.
I just pipx install poetry==1.1.8 so I can get on with my day.

@finswimmer
Copy link
Member

@iSplasher please open a new issue with steps to reproduce.
This ticket here is closed for a long time.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.