Python 在alpine docker容器中安装multidict时,如何修复gcc错误?

Python 在alpine docker容器中安装multidict时,如何修复gcc错误?,python,gcc,alpine,Python,Gcc,Alpine,问: 在我的docker容器中,我使用预先安装好的apline linux系统 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/5503ba866d8d216e49a6ce3bcb288df8a

问: 在我的docker容器中,我使用预先安装好的apline linux系统

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.
bash-4.4#pip安装multidict
收集多目录
使用缓存https://files.pythonhosted.org/packages/84/96/5503ba866d8d216e49a6ce3bcb288df8a5fb3ac8a90b8fcff9ddcda32568/multidict-4.7.3.tar.gz
为收集的包构建轮子:multidict
正在为multidict构建控制盘(setup.py)。。。错误
错误:命令出错,退出状态为1:
命令:/usr/local/bin/python-u-c'import sys、setuptools、tokenize;sys.argv[0]=“tmp/pip-install-79jceuft/multidict/setup.py”“”__文件\ \=''''''/tmp/pip-install-79jceuft/multidict/setup.py'';f=getattr(标记化,“'open'”,open)(\uuuuu文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(编译(代码,uuuu文件,“'exec'”)'bdist_wheel-d/tmp/pip-wheel-57k4lw21——python标记cp37
cwd:/tmp/pip-install-79jceuft/multidict/
....
/usr/local/include/python3.7m/Python.h:11:20:致命错误:limits.h:没有这样的文件或目录
#包括
^
编译终止。
错误:命令“gcc”失败,退出状态为1
----------------------------------------
错误:命令出错,退出状态为1:/usr/local/bin/python-u-c'import sys、setuptools、tokenize;sys.argv[0]=“tmp/pip-install-79jceuft/multidict/setup.py”“”__文件\ \=''''''/tmp/pip-install-79jceuft/multidict/setup.py'';f=getattr(标记化,“'open'”,open)(\uuuuu文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(compile(compile(代码,_文件,“'exec'))'安装--record/tmp/pip-record-lomj_vmk/install-record.txt--外部管理的单一版本--编译检查日志以获得完整的命令输出。

如何解决此问题?

预安装gcc和其他环境

e、 g


简单的修复方法是在dockerfile中添加以下命令:

RUN apk --no-cache add gcc musl-dev

感谢@ZoionLee的提示。

遇到此问题,是什么解决了我的问题,而无需在系统上安装
sudo

$ pip install --upgrade pip setuptools-scm

我也是在虚拟环境中这样做的。

有帮助吗?我已经安装了musl设备来修复它
$ pip install --upgrade pip setuptools-scm