pipenv: Confusing error message when run in Dockerfile
When experimenting in a Dockerfile, I hit an odd error message:
Creating a virtualenv for this project…
usage: pew [-h] [-p PYTHON] [-i PACKAGES] [-r REQUIREMENTS] [-d] [-a PROJECT]
envname
pew: error: the following arguments are required: envname
Virtualenv location:
Creating a Pipfile for this project…
Creating a virtualenv for this project…
usage: pew [-h] [-p PYTHON] [-i PACKAGES] [-r REQUIREMENTS] [-d] [-a PROJECT]
envname
pew: error: the following arguments are required: envname
Virtualenv location:
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
An unexpected error occurred while accessing your virtualenv's python installation!
Please run $ pipenv --rm to re-create your environment.
Obviously a Dockerfile is a pathological environment to be running in (and I’ve moved on to resolve the issue), but it feels like pipenv should abort much earlier than it did
Describe your environment
- OS Type: ubuntu:16.04
- Python version: 3.5
- Pipenv version: latest from PyPI
Expected result
Error message explaining the actual issue.
Actual result
Above error message.
Steps to replicate
Attempt to build this Dockerfile:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y python3-pip
RUN pip3 install pipenv
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN pipenv install --deploy --verbose
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 16
- Comments: 17 (11 by maintainers)
Can we reopen this?
I disagree that Docker is “a pathological environment”! In particular, if Pipenv doesn’t work out of the box with an official Python Docker image, something is wrong (though I’m not sure whether it’s the image or Pipenv that should be fixed.)
FWIW, here’s my repro:
Output:
In case it helps others I was able to solve this issue by setting
WORKDIR
to/opt/app
:pipenv --three
definitely is supposed to work (I use it too)/
has noname
and thus cannot be hashed for generating virtualenv or (2) python version and path problems. So for now, the solution is to make theWORKDIR
not be/
(which is the default). For context - pipenv hashes the/
to figure out virtualenv name, and I think when it doesn’t exist it hits a pathological codepath…I had a similar issue and it was just that PYTHONPATH and PYTHON_VERSION environment variables weren’t set in the docker container.
An example of my dockerfile can be found at: https://gist.github.com/aljp/811030019a711532eda77cf07408458a
I’m currently using this docker image in a circleci build and it works there, however, when I attempt to run the circleci builds or
docker run
locally I get the same error.If you build that image and run
docker run -it --rm my/repo:circleci-latest /bin/bash
and then runpipenv install --dev
you’ll see the error:Turns out the docker container was just missing the
PYTHONPATH
andPYTHON_VERSION
environment variables, so running the container withdocker run -it --rm -e PYTHONPATH=/usr/local/bin -e PYTHON_VERSION="3.6.1" my/repo:circleci-latest /bin/bash
seems to work.Perhaps reopen this? Here’s a minimal reproducer:
I can’t control how it is run, ie I need to make the Dockerfile work on its own, but so far I haven’t fixed the problem with
ENV
statements.