[英]How can I fix gcc error when install multidict in alpine docker container?
問:在我的 docker 容器中,我使用的是 apline linux 系統,它已經預先安裝了 gcc
apk信息:
bash-4.4# apk info
....
gcc
但是當我安裝 multidict 時,因 gcc 錯誤而失敗
bash-4.4# pip install multidict
Collecting multidict
Using cached https://files.pythonhosted.org/packages/84/96/5503ba866d8d216e49a6ce3bcb288df8a5fb3ac8a90b8fcff9ddcda32568/multidict-4.7.3.tar.gz
Building wheels for collected packages: multidict
Building wheel for multidict (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-79jceuft/multidict/setup.py'"'"'; __file__='"'"'/tmp/pip-install-79jceuft/multidict/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-57k4lw21 --python-tag cp37
cwd: /tmp/pip-install-79jceuft/multidict/
....
/usr/local/include/python3.7m/Python.h:11:20: fatal error: limits.h: No such file or directory
#include <limits.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-79jceuft/multidict/setup.py'"'"'; __file__='"'"'/tmp/pip-install-79jceuft/multidict/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-lomj_vmk/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
我該如何解決這個問題?
簡單的解決方法是在 dockerfile 中添加以下命令:
RUN apk --no-cache add gcc musl-dev
感謝@Zosionlee 的提示。
預裝gcc等環境。
例如
RUN apk update \
&& apk add --no-cache gcc git python3-dev musl-dev linux-headers
libc-dev rsync zsh \
findutils wget util-linux grep libxml2-dev libxslt-dev \
&& pip3 install --upgrade pip
遇到此問題,無需在系統上安裝sudo
即可解決我的問題:
$ pip install --upgrade pip setuptools-scm
我也在虛擬環境中這樣做了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.