pipenv: Pipenv doesn't resolve --system python correctly.

Describe you environment
  1. OS Type Docker Alpine Python -> https://github.com/docker-library/python/blob/1d59eb2dd813c64891bf554a8ea01754aba25816/3.6/alpine3.6/Dockerfile
  2. Python version: Python 3.6.3
  3. Pipenv version: 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 on pipenv install --system

Why I know this? Because there is other function that works incorrectly.

'/bin/python'
(Pdb) which('python')
'/bin/python'
(Pdb) print(sys.executable)
'/usr/local/bin/python'

/ # /bin/python
sh: /bin/python: not found

I think issue is somewhere here: https://github.com/kennethreitz/pipenv/blob/1bf6f5101a3bf1dca78be814e742411cc5bdb2dd/pipenv/cli.py#L1440

            p = os.sep.join([location] + ['bin/{0}'.format(command)])

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 fail

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 46 (19 by maintainers)

Commits related to this issue

Most upvoted comments

no movement in 30 days. it’ll come back up if its important

@kennethreitz issue is not resolved, can You don’t close things that aren’t fixed yet. Issue is still reproducible.

I can repro the problem in master. Although it is closed, the PR #1097 that suppose to solve this problem didn’t actually get merged into master. Please reopen

I just tried, pip install git+git://github.com/pypa/pipenv.git@master and pipenv install --dev --system started working in my python:3.6.3 docker image. Can another release be made?

@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.

This will be resolved by #1097 if and when it is merged

Sorry for the ongoing trouble here folks, we had some trouble with our testing infrastructure but we will get this looked at

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"]

Unfortunately I’m still running into this in both python:3.6.3 and ubuntu:17.10 containers, with all versions of pipenv mentioned here, including the one suggested by @sbdchd .

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!

@LuRsT I just install via the git commit sha, which has the fix.

Currently waiting for a new release.

RUN set -ex && pip install git+git://github.com/pypa/pipenv.git@8378a1b104f2d817790a05da370bef0a1b00f452

EDIT: you will need to install git for this to work.

Hi there!

Just got the same issue here with the python:3.6 Docker image and pipenv-11.9.0.

Here’s a Dockerfile sample:

FROM python:3.6

WORKDIR /app
COPY . /app/

RUN pip install pipenv
RUN pipenv install --system

EXPOSE 8000

CMD ["python", "main.py"]

For now, I’m using @Jitsusama work-around.

Thanks.

I have added a work-around that is pretty simple to use in Docker in #917. The comment is https://github.com/pypa/pipenv/issues/917#issuecomment-375312947. 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?

Pass system to the function, where which is being passed, and pass it to the passed which.

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 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.

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