Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to install python pandas package on alpine image 3.7.2-alpine3.9 #381

Closed
Hubbitus opened this issue Feb 15, 2019 · 6 comments
Closed
Labels
question Usability question, not directly related to an error with the image

Comments

@Hubbitus
Copy link

Hubbitus commented Feb 15, 2019

Minimal reproduce:

FROM python:3.7.2-alpine3.9
RUN pip3 install pandas

Which lead to error:

Step 2/2 : RUN pip3 install pandas
 ---> Running in a27cff99becc
Collecting pandas
  Downloading https://files.pythonhosted.org/packages/81/fd/b1f17f7dc914047cd1df9d6813b944ee446973baafe8106e4458bfb68884/pandas-0.24.1.tar.gz (11.8MB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 359, in get_provider
        module = sys.modules[moduleOrReq]
    KeyError: 'numpy'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-mwz8syxn/pandas/setup.py", line 732, in <module>
        ext_modules=maybe_cythonize(extensions, compiler_directives=directives),
      File "/tmp/pip-install-mwz8syxn/pandas/setup.py", line 475, in maybe_cythonize
        numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1144, in resource_filename
        return get_provider(package_or_requirement).get_resource_filename(
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 361, in get_provider
        __import__(moduleOrReq)
    ModuleNotFoundError: No module named 'numpy'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-mwz8syxn/pandas/
The command '/bin/sh -c pip3 install pandas' returned a non-zero code: 1

Problem similar with tag 3.7.2-alpine3.8 too.

That works as expected with 3.7.2-slim! Like:

FROM python:3.7.2-slim
RUN pip3 install pandas
@tao12345666333
Copy link
Contributor

tao12345666333 commented Feb 15, 2019

Alpine Linux doesn't support PEP 513, every time we install packages on Alpine Linux we need re-building.

You could try this below:

FROM python:3.7.2-alpine3.9
RUN apk add --no-cache python3-dev libstdc++ && \
    apk add --no-cache g++ && \
    ln -s /usr/include/locale.h /usr/include/xlocale.h && \
    pip3 install numpy && \
    pip3 install pandas

@Hubbitus
Copy link
Author

You could try this below

As I say initially it build on 3.7.2-slim version without issues and additional packages.

@wglambert
Copy link

His Dockerfile has the wrong FROM:, switch it to Alpine and that will build numpy and pandas.

The issue is pip uses manylinux1 wheels which doesn't support Alpine's musl #341 (comment)
Which means that you'll be installing the packages from source.

I would advise using python:slim which supports the manylinux1 wheels. and also saves considerable time and space comparatively.

$ docker images | grep python
python     3.7.2-alpine3.9      2d23e3e6584b        3 days ago          86.7MB
python     slim                 96c349a2897f        3 days ago          143MB

python     slim-pandas          7612a34bbac1        2 minutes ago       293MB
python     alpine-pandas        d0b3edf1be62        6 minutes ago       435MB
$ docker history python:slim-pandas
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
7612a34bbac1        13 minutes ago      /bin/sh -c pip3 install pandas                  149MB
. . .

$ docker history python:alpine-pandas
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
d0b3edf1be62        17 minutes ago      /bin/sh -c apk add --no-cache python3-dev li…   348MB
. . .

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Feb 16, 2019
@tao12345666333
Copy link
Contributor

sorry the FROM just a typo, fixed.

@wglambert
Copy link

Closing since this question seems sufficiently answered, thanks @tao12345666333 for the Dockerfile

@jtlz2
Copy link

jtlz2 commented Apr 11, 2019

@docker-library docker-library locked as resolved and limited conversation to collaborators Apr 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

4 participants