Skip to content

Failed to install python modules using pip install base on python:2.7.15-alpine3.8 #349

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

Closed
dodoflyy opened this issue Nov 1, 2018 · 4 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@dodoflyy
Copy link

dodoflyy commented Nov 1, 2018

Hello, I want to install some python modules base on python:2.7.15-alpine3.8 but always failed.
Here is my Dockerfile :

FROM python:2.7.15-alpine3.8
# install python modules
COPY requirements.txt /build/RUN apk add --update curl gcc g++ \
    && rm -rf /var/cache/apk/* \
&& pip install --upgrade pip \
&& pip install setuptools --upgrade \
&& pip install -r /build/requirements.txt

Here is my requirements.txt :

scipy
pathlib
python-docx
pandas
mysql-connector-python==8.0.12
xlrd

There is too much warning or error information, I will post some of them.

      File "/usr/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 943, 
in _get_configuration_from_setup_py        config = setup_module.configuration(*args)
      File "scipy/linalg/setup.py", line 19, in configuration
        raise NotFoundError('no lapack/blas resources found')
    numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
    
    ----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install
-_nrjIx/scipy/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-nYcbQS/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-_nrjIx/scipy/
   #include "libxml/xmlversion.h"
                                 ^  compilation terminated.
  Compile failed: command 'gcc' failed with exit status 1
  creating tmp
  cc -I/usr/include/libxml2 -c /tmp/xmlXPathInitKognPA.c -o tmp/xmlXPathInitKognPA.o
  /tmp/xmlXPathInitKognPA.c:1:26: fatal error: libxml/xpath.h: No such file or directory
   #include "libxml/xpath.h"
                            ^
  compilation terminated.
  *********************************************************************************
  Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
  *********************************************************************************
  error: command 'gcc' failed with exit status 1
  
  ----------------------------------------
  Running setup.py clean for lxml
  Failed building wheel for lxml
  pandas/_libs/testing.c: In function 'inittesting':
    ^~~~~~~
  pandas/_libs/internals.c: In function '__pyx_gb_6pandas_5_libs_9internals_12generator':  pandas/_libs/internals.c:9336:36: warning: '__pyx_t_23' may be used uninitialized in this 
function [-Wmaybe-uninitialized]           __pyx_cur_scope->__pyx_t_9 = __pyx_t_23;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~  pandas/_libs/internals.c:9333:36: warning: '__pyx_t_11' may be used uninitialized in this 
function [-Wmaybe-uninitialized]           __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~  pandas/_libs/internals.c:9330:36: warning: '__pyx_t_6' may be used uninitialized in this f
unction [-Wmaybe-uninitialized]           __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~  pandas/_libs/internals.c:9335:36: warning: '__pyx_t_15' may be used uninitialized in this 
function [-Wmaybe-uninitialized]           __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~  pandas/_libs/internals.c:9334:36: warning: '__pyx_t_12' may be used uninitialized in this function [-Wmaybe-uninitialized]           __pyx_cur_scope->__pyx_t_7 = __pyx_t_12;           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

I hope somebody knows why and how to fix. Thanks.

@tao12345666333
Copy link
Contributor

see #318 .

@tao12345666333
Copy link
Contributor

Alpine Linux doesn't support Python PEP513. So when you use Alpine Linux based image to install some packages, it needs to compile. (you must install gcc and other packages for this.)

@dodoflyy
Copy link
Author

dodoflyy commented Nov 1, 2018

Alpine Linux doesn't support Python PEP513. So when you use Alpine Linux based image to install some packages, it needs to compile. (you must install gcc and other packages for this.)

Thanks for you reply. I go see #318 and install gcc, still don't work. I want to know what's other packages, where can I know the list? I can pip install from python:2-stretch.

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Nov 1, 2018
@wglambert
Copy link

I can't figure out why Alpine won't at least install those packages from source. I would highly recommend in your use case to just use Debian. The packages you're installing probably eclipse the size benefit of using Alpine and it seems you have to install most if not all of those packages from source on Alpine which currently exhibit numerous issues preventing their installation, whereas Debian can use manylinux wheels that install in literally 10 seconds. I had thought that Alpine can use none wheels but they were not supported wheel on this platform when I specified them.

Also if that's your complete Dockerfile you'll probably want to remove gcc at the end of the RUN line as it's 76MB which is 17MB bigger than the image, also g++ as well which is 64MB.

If you want to continue troubleshooting this perhaps https://serverfault.com/questions/771211/docker-alpine-and-matplotlib is relevant to the compiling issues. I can't figure out why the packages won't build from source, perhaps it's dependencies? Regardless there's nothing we could change in the image to remedy this. You could try asking the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

See also docker-library/docs#904 and #341 (comment) which is odd as I couldn't get the 2.7 none wheels to install when specifying their URL, and pip by default chose the .tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants