Pipenv: Pipenv install into docker container with --system, --deploy fails

Created on 15 Jul 2018  Â·  4Comments  Â·  Source: pypa/pipenv

Hello,
I cannot get pipenv to install the packages in a docker container. I've seen a bunch of issues that looks like this issue, but they all been closed and dealth with it seems.

Expected result

pipenv install --system --deploy --dev

Installs all packages correctly.

Actual result

It always fails with:

Warning: --system is intended to be used for Pipfile installation, not installation of specific packages. Aborting.
See also: --deploy flag.

I read in the documentation this is the way to do it with docker.

Issues somewhat related:

Dockerfile

FROM alpine:3.8
ENV PYTHONUNBUFFERED 1
ENV LANG en_US.UTF-8 \
    LANGUAGE en_US.UTF-8
RUN apk update \
    && apk add --no-cache --update python3 \
    && pip3 install --no-cache-dir -U pip pipenv \
    && pipenv install --system --deploy

Pipfile

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "*"

[dev-packages]

[requires]
python_version = "3.6"

Pipefile.lock

  • OS: Alpinelinux 3.8
  • Docker version: 18.05.0-ce
  • Python version: 3.6.6
  • Pipenv version: 2018.7.1

Sincerely,
Niclas

Most helpful comment

Sorry for the documentation leading you astray, it can definitely be clearer! The other issues you found (thanks for looking by the way) are probably even more confusing

In this case, you only need to know 2 pieces of super relevant but possibly not that clear information:

  • --deploy only works if you already have a lockfile -- by default pipenv will compare your lockfile to your pipfile (in both cases, assuming you have one), and if your lockfile is not in sync, it will re-lock and re-install. When you pass the --deploy flag, pipenv will instead _fail with an error_ and let you know that things are out of sync, rather than implicitly installing the new things.

  • --system similarly requires a lockfile. This argument allows you to use the system python installation (e.g. for docker installations), but generating lockfiles requires isolated environments (which your system environment is not). So when you pass these together without using a lockfile, it will fail. You need to generate the lockfile locally first, and copy it over with your pipfile into the docker container.

Thanks for filing the issue, hope this helps!

All 4 comments

Sorry for the documentation leading you astray, it can definitely be clearer! The other issues you found (thanks for looking by the way) are probably even more confusing

In this case, you only need to know 2 pieces of super relevant but possibly not that clear information:

  • --deploy only works if you already have a lockfile -- by default pipenv will compare your lockfile to your pipfile (in both cases, assuming you have one), and if your lockfile is not in sync, it will re-lock and re-install. When you pass the --deploy flag, pipenv will instead _fail with an error_ and let you know that things are out of sync, rather than implicitly installing the new things.

  • --system similarly requires a lockfile. This argument allows you to use the system python installation (e.g. for docker installations), but generating lockfiles requires isolated environments (which your system environment is not). So when you pass these together without using a lockfile, it will fail. You need to generate the lockfile locally first, and copy it over with your pipfile into the docker container.

Thanks for filing the issue, hope this helps!

### heklo

_asl;kfjllkaf
_

Not sure why all the thumbs down....

Step 7/11 : COPY . .
 ---> 4139dbe514d1
Step 8/11 : RUN pipenv install --system  --deploy --dev
 ---> Running in 062f79af2cf1
Installing dependencies from Pipfile.lock (c8d6db)…
Removing intermediate container 062f79af2cf1
 ---> c90c3773148c

Still not clear to me, for at least a couple of reasons.

  1. one is often stuck with an image with an older python. One can install more python versions using pyenv, and pass that particular python while installing deps with pipenv, but then one cannot use --system (the system python is the wrong one). It all works, but then at runtime, I am not sure how use that virtualenv (i.e., RUN pipenv shell fails)

  2. I work on a Mac. I cannot generate a lockfile locally and pass it to pipenv, because locked versions are not compatible with linux

Any more tips to work with Pipenv inside dockers?

Was this page helpful?
0 / 5 - 0 ratings