-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Pipenv doesn't resolve --system python correctly. #1002
Comments
@galuszkak this is interesting. So As for why we are doing all of this, it’s mainly so that we can trick the pip-fools package resolver to resolve python packages for versions of python that are different from the active interpreter |
Using this Dockerifle, which is based on the one commited to this repo I cannot reproduce this issue, not saying it doesn't exist, looks like something is up, buy this dockerfile seems to work: FROM python:alpine3.6
# -- Install Pipenv:
RUN set -ex && pip install pipenv --upgrade
# -- Install Application into container:
RUN set -ex && mkdir /app
WORKDIR /app
# -- Adding Pipfiles
ONBUILD COPY Pipfile Pipfile
ONBUILD COPY Pipfile.lock Pipfile.lock
# -- Install dependencies:
ONBUILD RUN set -ex && pipenv install --deploy --system |
@erinxocon I didn't use --deploy flag + You aren't using $PIP_PYTHON_PATH which is original issue here which is overriden by pipenv. |
@galuszkak Apologies; I understand that, I guess I am unsure why this needs to be set in this case. We should definitely address this bug and fix it. I'm just wondering if there is more going on with docker alpine which required the PIP_PYTHON_PATH being set. |
@erinxocon nothing to apologise :), thanks for looking to my issue 👍 . The fix that I supply in #1005 is working for me right now. But I tried your image and it's working perfectly fine with same set of things. Trying to naildown what is causing my problem in first place, because sam Pipfile and Pipfile.lock and same .env file sounds work on Your Dockerfile, and I don't see a difference because I source same image... |
Got it @erinxocon ! Here is how can You reproduce that:
Pipfile:
|
Seems to be a problem with using ONBUILD RUN vs just RUN. Not being a docker expert I'll have to figure out what the difference is between them. |
@erinxocon I don't think that's the problem. In example above I show You problem inside running container not on any step building image. |
@erinxocon the problem is with setting the variable in the first place (which doesn't actually need to be set but that's beside the point) -- by setting def which(command, location=None, allow_global=False):
if location is None:
location = project.virtualenv_location
if not allow_global:
if os.name == 'nt':
p = find_windows_executable(os.path.join(location, 'Scripts'), command)
else:
p = os.sep.join([location] + ['bin/{0}'.format(command)])
else:
if command == 'python':
p = sys.executable
return p Since @galuszkak is using
That's how we wind up with |
@galuszkak Apologies I didn't see the -it sh flag passed in your example. @techalchemy makes sense. Do you have a patch in the works, or should I take that on? |
@erinxocon @galuszkak already wrote a patch (#1005) which @nateprewitt had expressed some concerns about but I'm not sure where that leaves it |
@erinxocon again, nothing to apologies and really thanks for looking into my issue. Can we agree/disagree on #1005 as a fix? I will try move discussion further on that PR. |
This issue hit me again today, but on OS X in totally different conditions. Stack trace below.
|
My shell was ZSH. After setting LC_ALL and LANG in .zshrc everything works fine. But I'm not sure why LANG/LC_ALL should have any impact on choosing python interpreter. |
@galuszkak it is specifically an issue on Mac because of locale issues, I'll try to remember tomorrow to track down an early issue in this project where Kenneth discussed the problem with the default shell config but basically if your locale isn't set right python dies horribly As for the PR I think we needed nate to sign off, let me ping him over in the PR |
Pass |
@kennethreitz issue is not resolved, can You don't close things that aren't fixed yet. Issue is still reproducible. |
no movement in 30 days. it'll come back up if its important |
I'm with this problem on alpine images. Any solution?
|
This will be resolved by #1097 if and when it is merged |
@kennethreitz issue has 23 days now not 30 days, so You closed it too quickly. Also there is pending PR after first one was closed. So there is still pending action on this issue... Please reopen issue. |
Hi, i just found this issue today, is there another way of using Pipenv in an alpine container? |
@LuRsT I just install via the git commit sha, which has the fix. Currently waiting for a new release.
EDIT: you will need to install git for this to work. |
Cool, thanks @sbdchd! |
Unfortunately I'm still running into this in both Edit: Sorry that was a little unhelpful. I wasn't able to recreate it with a more minimal Dockerfile, so it must be something specific (and probably stupid) I'm doing. I'll report back if I find it! |
Here is the Dockerfile I am using for dev: FROM python:3.6
ENV PYTHONUNBUFFERD 1
RUN apt-get update
RUN apt-get install netcat -y
# -- Install Pipenv:
RUN set -ex && pip install git+git://github.com/pypa/pipenv.git@8378a1b104f2d817790a05da370bef0a1b00f452
# -- Install Application into container:
RUN set -ex && mkdir /app
WORKDIR /app
# -- Adding Pipfiles
COPY Pipfile Pipfile
COPY Pipfile.lock Pipfile.lock
# -- Install dependencies:
RUN set -ex && pipenv install --dev --system
WORKDIR /app
VOLUME ["/app"] |
Thanks for that. As it turns out, the error in my case was happening when attempting to create a lock file. Am transitioning some projects from |
I have added a work-around that is pretty simple to use in Docker in #917. The comment is #917 (comment). While not ideal, I do think that it is quite simple. @mcgeeco; my scenario was similar to yours for wanting this, so maybe you'll find my work-around useful? |
Hi there! Just got the same issue here with the Here's a Dockerfile sample:
For now, I'm using @Jitsusama work-around. Thanks. |
Same here, still being hit by this. |
Sorry for the ongoing trouble here folks, we had some trouble with our testing infrastructure but we will get this looked at |
Hi, I am using the latest version of the library 11.10.0 and still seeing this issue. The base image is ubuntu:xenial.
|
@Ankitmaroo sorry for the frustration, as a few people mentioned in various places (I know there is a lot to cover on this by now) the critical piece is to make sure you don't just use |
@techalchemy unfortunately, I cannot confirm that. My minimal Dockerfile: FROM python:3.6-alpine3.7
ENV PYTHONUNBUFFERED=1
WORKDIR app/
COPY Pipfile* app/
RUN set -x \
&& pip install --upgrade pip setuptools wheel pipenv \
&& pipenv install --system --dev and the error: + pipenv install --system --dev
Creating a Pipfile for this project…
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 366, in install
selective_upgrade=selective_upgrade,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1730, in do_install
skip_requirements=skip_requirements,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 634, in ensure_project
ensure_pipfile(validate=validate, skip_requirements=skip_requirements)
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 288, in ensure_pipfile
project.create_pipfile(python=python)
File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 585, in create_pipfile
'python_version': python_version(required_python)[: len('2.7')]
TypeError: 'NoneType' object is not subscriptable which is the same as in #1939. These are the installed versions:
If instead I sym-link the python binary everything is fine. RUN set -x \
&& pip install --upgrade pip setuptools wheel pipenv \
&& ln -sf /usr/local/bin/python /bin/python \
&& pipenv install --system --dev |
@Midnighter are you actually copying a pipfile over? |
Yes [[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
Flask = "*"
[dev-packages]
pytest = "*"
[requires]
python_version = "3.6" |
Agree with @Midnighter. Still, see the same error as above. |
@Midnighter you can't set your FROM python:3.6-alpine3.7
ENV PYTHONUNBUFFERED=1
COPY Pipfile* app/
WORKDIR app/
RUN set -x \
&& pip install --upgrade pip setuptools wheel pipenv \
&& pipenv install --system --dev |
What Docker version are you on? You are correct, I made a mistake in simplifying the Dockerfile but neither the version that you posted here nor another version worked for me. I am on + pipenv install --system --dev
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
ython: not found When I use it as I originally intended. FROM python:3.6-alpine3.7
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY Pipfile* /app/
RUN set -x \
&& pip install --upgrade pip setuptools wheel pipenv \
&& pipenv install --system --dev I get the same error. |
|
Why is a lock file a requirement for finding the Python executable? Especially since I'm not even using the |
@Midnighter because pipenv has to do dependency resolution which means it had to lock unless it has a lockfile. But, if you pass |
Describe you environment
Docker Alpine Python
-> https://github.com/docker-library/python/blob/1d59eb2dd813c64891bf554a8ea01754aba25816/3.6/alpine3.6/DockerfilePython 3.6.3
pipenv, version 8.3.1
Expected result
If I set PIP_PYTHON_PATH it's ignored and overrided by pipenv (my question is why, what's reasoning behind that?) because https://github.com/kennethreitz/pipenv/blob/master/pipenv/utils.py#L367 It's overriding this ENV variable when I use flag
--system
. I've catched that issue because when building my docker image it was failing onpipenv install --system
Why I know this? Because there is other function that works incorrectly.
I think issue is somewhere here: https://github.com/kennethreitz/pipenv/blob/1bf6f5101a3bf1dca78be814e742411cc5bdb2dd/pipenv/cli.py#L1440
this should return
/usr/local/bin/python
but for some strange reason it's returning/bin/python
Actual result
pipenv install --system
should install not failed that /bin/python is not found.Steps to replicate
pipenv install --system
on that docker image will failThe text was updated successfully, but these errors were encountered: