-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unable to install Cython on alpine image #312
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
Comments
You need FROM python:3.6-alpine
RUN apk add --no-cache --virtual .build-deps gcc musl-dev \
&& pip install cython \
&& apk del .build-deps $ docker build . -t python:test
Sending build context to Docker daemon 3.584kB
Step 1/2 : FROM python:3.6-alpine
---> 148efb059c7f
Step 2/2 : RUN apk add --no-cache --virtual .build-deps gcc musl-dev && pip install cython && apk del .build-deps
---> Running in 857a2a6e9ad8
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/12) Installing binutils (2.31.1-r2)
(2/12) Installing gmp (6.1.2-r1)
(3/12) Installing isl (0.18-r0)
(4/12) Installing libgomp (8.3.0-r0)
(5/12) Installing libatomic (8.3.0-r0)
(6/12) Installing libgcc (8.3.0-r0)
(7/12) Installing mpfr3 (3.1.5-r1)
(8/12) Installing mpc1 (1.0.3-r1)
(9/12) Installing libstdc++ (8.3.0-r0)
(10/12) Installing gcc (8.3.0-r0)
(11/12) Installing musl-dev (1.1.20-r4)
(12/12) Installing .build-deps (0)
Executing busybox-1.29.3-r10.trigger
OK: 115 MiB in 46 packages
Collecting cython
Downloading https://files.pythonhosted.org/packages/f8/da/c979464858b257b21a6472a85285548c91f5b4dc773cb049cfdfb3ceeb02/Cython-0.29.7.tar.gz (2.0MB)
Building wheels for collected packages: cython
Building wheel for cython (setup.py): started
Building wheel for cython (setup.py): still running...
Building wheel for cython (setup.py): finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/79/b9/15/c589b51f4e91b37faa76362180166a2041e4286c38dbc45fc6
Successfully built cython
Installing collected packages: cython
Successfully installed cython-0.29.7
WARNING: Ignoring APKINDEX.b89edf6e.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.737f7e01.tar.gz: No such file or directory
(1/12) Purging .build-deps (0)
(2/12) Purging gcc (8.3.0-r0)
(3/12) Purging binutils (2.31.1-r2)
(4/12) Purging libatomic (8.3.0-r0)
(5/12) Purging libgomp (8.3.0-r0)
(6/12) Purging musl-dev (1.1.20-r4)
(7/12) Purging mpc1 (1.0.3-r1)
(8/12) Purging mpfr3 (3.1.5-r1)
(9/12) Purging isl (0.18-r0)
(10/12) Purging gmp (6.1.2-r1)
(11/12) Purging libstdc++ (8.3.0-r0)
(12/12) Purging libgcc (8.3.0-r0)
Executing busybox-1.29.3-r10.trigger
OK: 18 MiB in 34 packages
Removing intermediate container 857a2a6e9ad8
---> d7415049e2e8
Successfully built d7415049e2e8
Successfully tagged python:test $ docker run --rm python:test pip freeze
Cython==0.29.7 |
Well, that's embarrassing. |
Just a quick comment to point out that using the 3 RUN commands above to delete dependencies will not make your image smaller, because it creates 3 different layers for the image. To effectively save space by removing the installed build dependencies, the 3 commands needs to be ran into one single RUN command, which creates a single layer:
also, Resulting image size:
|
If the above doesn't work for others, try installing python3-dev (or python2-dev as appropriate) in addition to gcc and musl-dev. apk add gcc musl-dev python3-dev
pip3 install cython |
I think something is missing, but can't understand what.
Trying it on the
python:3.6-alpine3.7
image.While running
pip install Cython
, I'm getting this error:gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.6m -c /tmp/pip-install-zsnsb46v/Cython/Cython/Plex/Scanners.c -o build/temp.linux-x86_64-3.6/tmp/pip-install-zsnsb46v/Cython/Cython/Plex/Scanners.o unable to execute 'gcc': No such file or directory error: command 'gcc' failed with exit status 1
Any help will be appreciated :)
The text was updated successfully, but these errors were encountered: