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

Unable to install MySQL-python package in alpine-python:2.7-slim #32

Closed
bguruprasad opened this issue Oct 9, 2018 · 2 comments
Closed

Comments

@bguruprasad
Copy link

Hi, I am trying to install python package MySQL-python==1.2.3rc1 in plain untouched image of alpine-python:2.7-slim. However I am not able to do the same. This happens for both jfloff/alpine-python:2.7 and jfloff/alpine-python:2.7-slim. Please find below errorlogs for more details about it.

[root@mysystem work]# docker run --rm -ti jfloff/alpine-python:2.7-slim -p MySQL-python==1.2.3rc1
First run, checking for any requirements...
Installing all APK requirements...
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
(1/27) Upgrading musl (1.1.18-r2 -> 1.1.18-r3)
(2/27) Installing binutils-libs (2.30-r1)
(3/27) Installing binutils (2.30-r1)
(4/27) Installing gmp (6.1.2-r1)
(5/27) Installing isl (0.18-r0)
(6/27) Installing libgomp (6.4.0-r5)
(7/27) Installing libatomic (6.4.0-r5)
(8/27) Installing libgcc (6.4.0-r5)
(9/27) Installing mpfr3 (3.1.5-r1)
(10/27) Installing mpc1 (1.0.3-r1)
(11/27) Installing libstdc++ (6.4.0-r5)
(12/27) Installing gcc (6.4.0-r5)
(13/27) Installing musl-dev (1.1.18-r3)
(14/27) Installing libc-dev (0.7.1-r0)
(15/27) Installing g++ (6.4.0-r5)
(16/27) Installing make (4.2.1-r0)
(17/27) Installing fortify-headers (0.9-r0)
(18/27) Installing build-base (0.5-r0)
(19/27) Installing libssh2 (1.8.0-r2)
(20/27) Installing libcurl (7.61.1-r0)
(21/27) Installing pcre2 (10.30-r0)
(22/27) Installing git (2.15.2-r0)
(23/27) Upgrading musl-utils (1.1.18-r2 -> 1.1.18-r3)
(24/27) Installing libc6-compat (1.1.18-r3)
(25/27) Installing linux-headers (4.4.6-r2)
(26/27) Upgrading python2 (2.7.14-r2 -> 2.7.15-r2)
(27/27) Installing python2-dev (2.7.15-r2)
Executing busybox-1.27.2-r7.trigger
OK: 240 MiB in 50 packages
Upgrading Pip...
Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 5.2MB/s 
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1
Installing all Pip requirements...
Collecting MySQL-python==1.2.3rc1 (from -r /tmp/requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/c8/8f/aedf47a2e973a2d2f225ac98537472fc928ad61b9647fb370870404c594b/MySQL-python-1.2.3c1.tar.gz (89kB)
    100% |████████████████████████████████| 92kB 293kB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-kmGDud/MySQL-python/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-kmGDud/MySQL-python/
[root@mysystem work]# docker run --rm -ti jfloff/alpine-python:2.7 bash
bash-4.4# pip install MySQL-python
Collecting MySQL-python
  Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 112kB 378kB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-P5QZtR/MySQL-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-P5QZtR/MySQL-python/
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
bash-4.4# exit
[root@mysystem work]#

Any hint will be great help!

@narate
Copy link

narate commented Oct 14, 2018

Hello @guruprasadbhavsar try this

docker run --rm -ti jfloff/alpine-python:2.7-slim -a mariadb-dev -p MySQL-python==1.2.3rc1

@bguruprasad
Copy link
Author

That solves my problem but increases this image size to ~340MB. I did something like below to create image below 100MB with MySQL python package installed.

FROM python:2.7-alpine

RUN set -ex \
    && apk add --no-cache --virtual .build-deps \
            gcc \
            make \
            libc-dev \
            musl-dev \
            linux-headers \
            pcre-dev \
            python-dev \
    && apk add --no-cache mariadb-dev \
    && sed '/st_mysql_options options;/a unsigned int reconnect;' /usr/include/mysql/mysql.h -i.bkp \
    && pip install --no-cache-dir MySQL-python==1.2.3rc1 \
    && runDeps="$( \
            scanelf --needed --nobanner --recursive /venv \
                    | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
                    | sort -u \
                    | xargs -r apk info --installed \
                    | sort -u \
    )" \
    && apk add --virtual .python-rundeps $runDeps \
    && apk del .build-deps

This generates image with size just ~88MB

@jfloff jfloff closed this as completed Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants