我有以下Pipfile:

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

[packages]
mypy = "==0.521"

[requires]
python_version = "3.6"

Dockerfile:
FROM heroku/heroku:18

#Install system dependencies
RUN apt-get update && apt-get install -y software-properties-common build-essential curl nano

#Install python 3.6
RUN apt-get update
RUN apt-get install -y python3.6 libpython3.6 python3.6-dev python-dev python-pip \
    python3-pip libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev

#Install backend packages
RUN pip3 install pipenv python-magic libmagic django
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

镜像构建并启动容器
docker build -t test -f Dockerfile .
docker run -it test /bin/bash

将Pipfile复制到容器
docker cp Pipfile <container>:/test/Pipfile

生成锁文件
pipenv lock

尝试安装软件包
pipenv install --dev --system --python=`which python3`

错误
    An error occurred while installing mypy==0.521! Will try again.
An error occurred while installing typed-ast==1.0.4! Will try again.
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 2/2 — 00:00:01
Installing initially failed dependencies...
Collecting mypy==0.521 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/2 — 00:00:00
  Using cached https://files.pythonhosted.org/packages/18/11/733e33decfdbd76cce7158c92618b9317d4132b41affd04db00216d17f76/mypy-0.521.tar.gz
    Complete output from command python setup.py egg_info:
    ERROR: You need Python 3.2 or later to use mypy.

    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cebwoI/mypy/

  ☤  ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/2 —

最佳答案

问题出在--system。这使pipenv使用pip命令-解析为2.7点的/usr/bin/pip
我看到如果删除--system标志,它将正常运行。

root@5ce055e3cd89:~# pipenv install --dev --python 3
Virtualenv already exists!
Removing existing virtualenv...
Creating a virtualenv for this project...
Pipfile: /root/Pipfile
Using /usr/bin/python3 (3.6.6) to create virtualenv...
⠋Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /root/.local/share/virtualenvs/root-BuDEOXnJ/bin/python3
Also creating executable in /root/.local/share/virtualenvs/root-BuDEOXnJ/bin/python
Installing setuptools, pip, wheel...done.
Setting project for root-BuDEOXnJ to /root

Virtualenv location: /root/.local/share/virtualenvs/root-BuDEOXnJ
Installing dependencies from Pipfile.lock (0f51af)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 2/2 — 00:00:01
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

08-07 19:30