Dan Cohen
Dan Cohen

Reputation: 81

pip complains about package

I'm trying to install cffi package because bcrypt depends on it but I keep getting this error which makes no sense to me. It says it can't find relevant version of cffi but in requirements file I've got the latest version listed.

Why am I getting this error ?

I'm building image with Docker using:

FROM python:3.6.5-alpine

WORKDIR /app
ADD . /app
RUN pip3 install -r requirements.txt
EXPOSE 5000
CMD ["python", "main.py"]   # I've got set alias on Python == Python 3.6

requirements.txt:

alembic==1.0.9
cffi==1.12.3
bcrypt==3.1.6
blinker==1.4
Click==7.0
Faker==1.0.5
Flask==1.0.2
Flask-Bcrypt==0.7.1
Flask-Login==0.4.1
Flask-Mail==0.9.1
Flask-Migrate==2.4.0
Flask-Moment==0.7.0
Flask-Script==2.0.6
Flask-SQLAlchemy==2.3.2
Flask-Testing==0.7.1
Flask-WTF==0.14.2
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
PyMySQL==0.9.3
SQLAlchemy==1.3.3
text-unidecode==1.2
Werkzeug==0.15.2
WTForms==2.2.1

However, when building:

Step 1/6 : FROM python:3.6.5-alpine
---> 5be6d36f77ee
Step 2/6 : WORKDIR /app
---> Using cache
---> f9e7cc24d767
Step 3/6 : ADD . /app
---> 7d9d5bdcf5d6
Step 4/6 : RUN pip3 install -r requirements.txt
---> Running in b455df1a48e2
Collecting alembic==1.0.9 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/fc/42/8729e2491fa9b8eae160d1cbb429f61712bfc2d779816488c25cfdabf7b8/alembic-1.0.9.tar.gz (1.0MB)
Collecting bcrypt==3.1.6 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/ce/3a/3d540b9f5ee8d92ce757eebacf167b9deedb8e30aedec69a2a072b2399bb/bcrypt-3.1.6.tar.gz (42kB)
Could not find a version that satisfies the requirement cffi>=1.1 (from versions: )
No matching distribution found for cffi>=1.1
You are using pip version 10.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

Upvotes: 1

Views: 950

Answers (1)

John
John

Reputation: 1704

Installing cffi requires gcc, which is not included in the alpine image.

If run

docker run -it python:3.6.5-alpine sh

then in the container run

pip install cffi==1.12.3

Will get:

    unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-juslf1fb/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-md66dk3u/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-juslf1fb/cffi/

To resolve this, you may use the stretch version of the python image instead, like:

FROM python:3.6.5-stretch

Upvotes: 2

Related Questions