Pipenv: `pipenv --system` fails when python is installed in /usr/local/bin

Created on 5 Mar 2018  Â·  11Comments  Â·  Source: pypa/pipenv

pipenv install --system --deploy --three fails to proceed as it tries to execute /bin/python instead of /usr/local/bin/python

Describe your environment
  1. OS Type ubuntu
  2. Python version: Python 3.6.1
  3. Pipenv version: pipenv, version 11.0.2
Expected result

All packages installed correctly.

Actual result

Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
/python: not found

Steps to replicate

pipenv install --system --deploy --three

Most helpful comment

I also have the same issue with pipenv >= 11. In Docker image python:3.6-slim-stretch command pipenv install --system fails to locate the python interpreter at /usr/local/bin/python3.
The error is the same:

/python: not found

All 11 comments

These flags don’t work the way you are using them. You can’t use —deploy unless you already have a lockfile, and —system is designed to use whatever the first python on your system path is. I’m not sure we had —three in mind when it was designed. This should error and exit, I can’t really think of any scenario where you would pass in —deploy and actually have the result be that a new lockfile is generated.

@techalchemy Thanks for response. I think that the problem here is that --system is trying to use /bin/python which doesn't exist. First and only python instance is in /usr/local/bin/python. In such circumstances --system will never succeed even with correct .lockfile provided.

I also have the same issue with pipenv >= 11. In Docker image python:3.6-slim-stretch command pipenv install --system fails to locate the python interpreter at /usr/local/bin/python3.
The error is the same:

/python: not found

I have also run into this error recently on pipenv 11.0.2 and python:2.7-slim-stretch

If someone can produce a Dockerfile that re–produces this issue, I'll re-open this ticket.

Here's a minimum Dockerfile that does it:

FROM python:2.7-slim-stretch
RUN mkdir -p /usr/app/src

WORKDIR /usr/app/src
RUN pip install pipenv --upgrade

COPY Pipfile /usr/app/src
RUN pipenv install --verbose --system

Pipfile:

[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]

[packages]

uwsgi = "*"

Error:

```Step 6/6 : RUN pipenv install --verbose --system
---> Running in ecede58f62bc
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…

/python: not found

/usr/local/lib/python2.7/site-packages/pipenv/utils.py:1147: ResourceWarning: Implicitly cleaning up
warnings.warn(warn_message, ResourceWarning)
```

Yes of course it will fail if you are using an interpreter at /usr/local/bin/python3 and you dont have it symlinked to /usr/local/bin/python -- nothing that attempts to run python will execute python3 unless there is a symlink telling it to do so. Additionally, you need to have /usr/local/bin on your path if it isn't:

RUN export PATH=/usr/local/bin:$PATH
RUN mkdir -p /usr/app/src

WORKDIR /usr/app/src
RUN set -ex && if [ -e /usr/local/bin/python3 ]; then ln -s /usr/local/bin/python3 /usr/local/bin/python; fi
RUN set -ex && if [ -e /usr/local/bin/pip3 ]; then ln -s /usr/local/bin/pip3 /usr/local/bin/pip; fi
RUN set -ex && pip install pipenv --upgrade --no-cache-dir

COPY Pipfile /usr/app/src
RUN pipenv install --verbose --system

/usr/local/bin/python is on my path in that dockerfile, and I can run which python getting /usr/local/bin/python . I think this is a regression from 10.1.2. I can fix with RUN ln -s /usr/local/bin/python /bin/python but I shouldn't have too.

No you shouldn’t I agree with that — if it’s linked properly then it’s a search problem so we can track this down

Is this fixed in Master?? I am using pipenv==11.9.0 and i still have the same problem. The workaround does work.

It should be fixed by #1943 - sorry this keeps cropping up folks

Was this page helpful?
0 / 5 - 0 ratings