Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when installing python3 packages in alpine

Tags:

I am currently building an image from alpine:3.7.

There are two packages that I am having problems with:

  • pendulum (specifically python-dateutils package)
  • service_identity (specifically attrs package)

The error that I receive it is:

Could not find a version that satisfies the requirement setuptools (from versions: ) No matching distribution found for setuptools

Note: all packages are pre-cached on a directory using pip download.

The dockerfile looks as follows:

RUN apk add --no-cache --virtual .build-deps <dev packages>
 && apk add --no-cache --update python3
 && pip3 install --upgrade pip setuptools

RUN pip3 install -f ./python-packages --no-index -r requirements.txt ./python-packages/pkgs

....

dev-packages such as libffi-dev, libressl-dev, etc.

like image 315
Diego Gallegos Avatar asked Apr 18 '18 16:04

Diego Gallegos


People also ask

Does Python 3.10 support pip?

Compatibility. The current version of pip works on: Windows, Linux and MacOS. CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.

How do I install Python 3 pip packages?

Install pip using Python 3's setuptools: run sudo easy_install3 pip , this will give you the command pip-3.2 like kev's solution. Install your PyPI packages: run sudo pip-3.2 install <package> (installing python packages into your base system requires root, of course). … Profit!

Does Alpine Linux have Python?

We have understood the advantages of Python and successfully installed its latest version in the Alpine Linux distribution.

Does Alpine image have Python?

Read the concise, action-oriented Python on Docker Production Handbook. As promised, Alpine images build faster and are smaller: 15 seconds instead of 30 seconds, and the image is 105MB instead of 150MB. That's pretty good!


1 Answers

I'm not sure about the full list of dev-packages to build in the question, but it should be the following: g++ (GNU C++ standard library and compiler), python3-dev (python3 development files), libffi-dev (libffi development files) and openssl-dev (Toolkit for SSL v2/v3 and TLS v1 development files).

The Dockerfile is:

FROM alpine:3.7
RUN apk add --no-cache --virtual .build-deps g++ python3-dev libffi-dev openssl-dev && \
    apk add --no-cache --update python3 && \
    pip3 install --upgrade pip setuptools
RUN pip3 install pendulum service_identity
like image 74
nickgryg Avatar answered Oct 21 '22 14:10

nickgryg