dockerでpython:3.6-alpineイメージを利用してへuwsgiのインストールしようとしたところ、エラー"Exception: you need a C compiler to build uWSGI"が発生しました。
$pip install uwsgi
...
Failed to build uwsgi
Running setup.py install for uwsgi: started
Running setup.py install for uwsgi: finished with status 'error'
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7jbb_um0/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-record-tjbpqoop/install-record.txt --single-version-externally-managed --compile:
/usr/local/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'descriptions'
warnings.warn(msg)
running install
using profile: buildconf/default.ini
detected include path: ['/usr/include', '/usr/local/include']
Traceback (most recent call last):
File "/tmp/pip-install-7jbb_um0/uwsgi/uwsgiconfig.py", line 742, 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-install-7jbb_um0/uwsgi/setup.py", line 138, in <module>
'Programming Language :: Python :: 3.6',
File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-install-7jbb_um0/uwsgi/setup.py", line 77, in run
conf = uc.uConf(get_profile())
File "/tmp/pip-install-7jbb_um0/uwsgi/uwsgiconfig.py", line 750, in __init__
raise Exception("you need a C compiler to build uWSGI")
Exception: you need a C compiler to build uWSGI
原因はエラーメッセージにあるようCコンパイラがインストールされていなかった為で、以下のようにRUN apk add
でコンパイラとヘッダファイルをインストールすることで、uwsgiのインストールに成功しました。
FROM python:3.6-alpine
RUN apk add gcc build-base linux-headers
RUN pip install uwsgi
こちらもおススメ