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 execute 'gcc': No such file or directory #60

Closed
dyrnade opened this Issue Aug 21, 2015 · 9 comments

Comments

Projects
None yet
7 participants
@dyrnade

dyrnade commented Aug 21, 2015

I was using pip to install cryptography lib and i get above errors. Dockerfile seems to install gcc however it doesnt have gcc.

unable to execute 'gcc': No such file or directory
unable to execute 'gcc': No such file or directory

No working compiler found, or bogus compiler options
passed to the compiler from Python's distutils module.
See the error messages above.
(If they are about -mno-fused-madd and you are on OS/X 10.8,
see http://stackoverflow.com/questions/22313407/ .)

error: Setup script exited with 1

@yosifkit

This comment has been minimized.

Member

yosifkit commented Aug 21, 2015

Which image are you using (python:3, python:2, python:slim)? What is its image id?

@dyrnade

This comment has been minimized.

dyrnade commented Aug 23, 2015

Sorry forgot to write , python:slim image

@yosifkit

This comment has been minimized.

Member

yosifkit commented Aug 24, 2015

Yeah, slim removes gcc to keep it as small as possible. With the slim image you'll need to install any build dependencies that you require for your pip installs. To keep the image slim, you'll also want to remove packages after you are done (in the same RUN that they are installed on) Something like the following with all the other packages you will need during the pip install.

RUN apt-get update \
    && apt-get install -y --no-install-recommends gcc and-build-dependencies \
    && rm -rf /var/lib/apt/lists/* \
    && pip install cryptography \
    && apt-get purge -y --auto-remove gcc and-build-dependencies
# the --no-install-recommends helps limit some of the install so that you can be more explicit about what gets installed
@jennolsen84

This comment has been minimized.

jennolsen84 commented Oct 19, 2015

@dyrnade if you really care about the size, the best way to do this is to build python wheels (by using an image that inherits from python:3) and save them in an external directory. Then when building your slimmer image you can just mount that wheelhouse and do a pip install. This is not trivial, but if size is important you can do this strategy.

https://glyph.twistedmatrix.com/2015/03/docker-deploy-double-dutch.html

@lithiumlab

This comment has been minimized.

lithiumlab commented May 2, 2016

im getting the same error in python 2.7
any suggestions?
using linux alpine

@tianon

This comment has been minimized.

Member

tianon commented May 2, 2016

The slim and alpine variants both only include the absolute bare minimum necessary to use the image. If your usage requires tools such as gcc, then you will need to do something like apk add --no-cache gcc.

@lithiumlab

This comment has been minimized.

lithiumlab commented May 2, 2016

Thanks.
Solved it with:

RUN mkdir /app
ADD /app/requirements.txt /app/requirements.txt
WORKDIR /app
RUN apk --update add python py-pip openssl ca-certificates py-openssl wget
RUN apk --update add --virtual build-dependencies libffi-dev openssl-dev python-dev py-pip build-base \
  && pip install --upgrade pip \
  && pip install -r requirements.txt \
  && apk del build-dependencies

@tianon tianon closed this Aug 8, 2016

@mikkiweesenaar

This comment has been minimized.

mikkiweesenaar commented Apr 24, 2017

@yosifkit
I get the following error on your suggestion.
I am using python:3.5.3-slim.

E: Unable to locate package and-build-dependencies
The command '/bin/sh -c apt-get update         && apt-get install -y --no-install-recommends gcc and-build-dependencies         && rm -rf /var/lib/apt/lists/*         && pip3 install -r /tmp/requirements.txt         && apt-get purge -y --auto-remove gcc and-build-dependencies' returned a non-zero code: 100
@sharego

This comment has been minimized.

sharego commented Jun 13, 2017

@mikkiweesenaar i guess and-build-dependencies means which some thing you need else, should replace it to real package names like python-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment