我在运行 Debian Stretch 的 Windows 10 WSL 上安装 pip 包时遇到问题。
在安装了 python3-pip
的情况下运行 sudo pip install Invoice2data
时,我遇到了以下错误。
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for regex
Running setup.py clean for regex
Failed to build regex
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex_2/_regex.c -o build/temp.linux-x86_64-2.7/regex_2/_regex.o
regex_2/_regex.c:46:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, okenize;__file__='/tmp/pip-install-D9zG6P/regex/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-0dvlsB/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-D9zG6P/regex/
最佳答案
WSL 与该问题无关,这是一个相当标准的错误。
确保安装了以下软件包。使用 apt-get install packagename 来安装它们。这次的问题已通过安装 python-dev
得到解决。
python3
python3-pip
ipython3
build-essential
python-dev
python3-dev
作为单个命令:
sudo apt-get install python3 python3-pip ipython3 build-essential python-dev python3-dev
关于python - 安装 pip 包时出现 "Failed building wheel for regex",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53744668/