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

[uwsgi] [Failed Installation] [python:3.4-alpine] - Unable to pip install uwsgi in python:3.4-alpine #184

Closed
anirbanroydas opened this issue Mar 23, 2017 · 6 comments

Comments

@anirbanroydas
Copy link

anirbanroydas commented Mar 23, 2017

I am trying to install uwsgi along with other pypy packages using a requirements.txt file. I am able to install everything except uwsgi. Its giving me the following error:

# requirements.txt
Flask == 0.12
uwsgi == 2.0.14
requests == 2.13.0
redis == 2.10.5
#Dockerfile
FROM python:3.4-alpine

RUN apk add --update --no-cache \
		pcre-dev 
# 		build-base \
#		python3-dev

RUN addgroup -S uwsgi && adduser -S -g uwsgi uwsgi

WORKDIR /ci_testing_python

COPY requirements.txt /ci_testing_python/
RUN pip install -r requirements.txt
# RUN pip install --verbose uwsgi

COPY ci_testing_python /ci_testing_python/ci_testing_python/
COPY setup.py /ci_testing_python/
COPY setup.cfg /ci_testing_python/

COPY tests /ci_testing_python/tests/

RUN pip install --no-deps .

EXPOSE 5000 9090 9191
USER uwsgi

CMD ["./docker-entrypoint.sh"]

So now when I try to run the build command, this is the following error that I get.

$ docker build -t myapp:latest .
Sending build context to Docker daemon 92.67 kB
Step 1/15 : FROM python:3.4-alpine
 ---> 9ac5db25a0ca
Step 2/15 : RUN apk add --update --no-cache             pcre-dev
 ---> Using cache
 ---> 97037b3e67f5
Step 3/15 : RUN addgroup -S uwsgi && adduser -S -g uwsgi uwsgi
 ---> Using cache
 ---> e4647269bef5
Step 4/15 : WORKDIR /ci_testing_python
 ---> Using cache
 ---> dbd5cbf04260
Step 5/15 : COPY requirements/requirements-main.txt /ci_testing_python/
 ---> 5b1ff8a4ba15
Removing intermediate container 163a45c9e6f1
Step 6/15 : RUN pip install -r requirements-main.txt
 ---> Running in 78ab52d5ef57
Collecting Flask==0.12 (from -r requirements-main.txt (line 1))
  Downloading Flask-0.12-py2.py3-none-any.whl (82kB)
Collecting uwsgi==2.0.14 (from -r requirements-main.txt (line 2))
  Downloading uwsgi-2.0.14.tar.gz (788kB)
Collecting requests==2.13.0 (from -r requirements-main.txt (line 3))
  Downloading requests-2.13.0-py2.py3-none-any.whl (584kB)
Collecting redis==2.10.5 (from -r requirements-main.txt (line 4))
  Downloading redis-2.10.5-py2.py3-none-any.whl (60kB)
Collecting Jinja2>=2.4 (from Flask==0.12->-r requirements-main.txt (line 1))
  Downloading Jinja2-2.9.5-py2.py3-none-any.whl (340kB)
Collecting itsdangerous>=0.21 (from Flask==0.12->-r requirements-main.txt (line 1))
  Downloading itsdangerous-0.24.tar.gz (46kB)
Collecting Werkzeug>=0.7 (from Flask==0.12->-r requirements-main.txt (line 1))
  Downloading Werkzeug-0.12.1-py2.py3-none-any.whl (312kB)
Collecting click>=2.0 (from Flask==0.12->-r requirements-main.txt (line 1))
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask==0.12->-r requirements-main.txt (line 1))
  Downloading MarkupSafe-1.0.tar.gz
Installing collected packages: MarkupSafe, Jinja2, itsdangerous, Werkzeug, click, Flask, uwsgi, requests, redis
  Running setup.py install for MarkupSafe: started
    Running setup.py install for MarkupSafe: finished with status 'done'
  Running setup.py install for itsdangerous: started
    Running setup.py install for itsdangerous: finished with status 'done'
  Running setup.py install for uwsgi: started
    Running setup.py install for uwsgi: finished with status 'error'
    Complete output from command /usr/local/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-zvqmmzqp/uwsgi/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-1l6suehh-record/install-record.txt --single-version-externally-managed --compile:
    running install
    using profile: buildconf/default.ini
    detected include path: ['/usr/include', '/usr/local/include']
    Traceback (most recent call last):
      File "/tmp/pip-build-zvqmmzqp/uwsgi/uwsgiconfig.py", line 734, in __init__
        gcc_version_components = gcc_version.split('.')
    AttributeError: 'NoneType' object has no attribute 'split'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-zvqmmzqp/uwsgi/setup.py", line 124, in <module>
        distclass=uWSGIDistribution,
      File "/usr/local/lib/python3.4/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/lib/python3.4/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python3.4/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-zvqmmzqp/uwsgi/setup.py", line 77, in run
        conf = uc.uConf(get_profile())
      File "/tmp/pip-build-zvqmmzqp/uwsgi/uwsgiconfig.py", line 742, in __init__
        raise Exception("you need a C compiler to build uWSGI")
    Exception: you need a C compiler to build uWSGI

    ----------------------------------------
Command "/usr/local/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-zvqmmzqp/uwsgi/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-1l6suehh-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-zvqmmzqp/uwsgi/
The command '/bin/sh -c pip install -r requirements-main.txt' returned a non-zero code: 1

What is wrong here?

I have also looked into unbit/uwsgi/issues/1318 and gliderlabs/docker-alpine/issues/158 but both of them use alpine:3.4 as the base image and hence when trying to apk add the required packages it throws some error in installing those mentioned packages in mentioned in those issues.

@yosifkit
Copy link
Member

You need to also install the build tools: gcc libc-dev linux-headers. You can add these to your apk add line or if you don't want to persist gcc in the final image you can install and remove in the line they are used:

RUN set -e; \
	apk add --no-cache --virtual .build-deps \
		gcc \
		libc-dev \
		linux-headers \
	; \
	pip install -r requirements-main.txt; \
	apk del .build-deps;

@anirbanroydas
Copy link
Author

@yosifkit Thanks. I made the above changes to my Dockerfile and it worked successfully. So my fundamental issue is solved.

But, there is a slight other problem that I noticed. I also tested with a different base image, python:3.6-alpine. But in both the variations, 3.4-alpine and 3.6-alpine. The size of the images after being pulled are quite larger than what is mentioned in the docker hub. I pulled it in an aws ec2 instance with ubuntu 16.04 as host OS. What is the reason for this?

Here is the screenshot.

screen shot 2017-03-25 at 2 18 28 pm

@anirbanroydas
Copy link
Author

@yosifkit Any update on this?

@yosifkit
Copy link
Member

The size mentioned on the Docker Hub is the compressed size, so the amount that would be downloaded when pulled, while the images list is the on disk size. Layers can shared between images (like everything up to line 18) can be shared between all the python alpine versions. It is not a huge saving here, since ca-certificates is fairly small, but can definitely help on the Debian based images that are from buildpack-deps.

@anirbanroydas
Copy link
Author

@yosifkit Thanks. Its clear now.

@jshuadvd
Copy link

@yosifkit is there any world where you would share your terminal theme? Here is mine.. It's similar, but not as awesome with the branches

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