python - 安装 pip 包时出现 "Failed building wheel for regex"

标签 python pip debian-stretch

我在运行 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/

相关文章:

linux - 在加载驱动程序时使用 udev 规则执行命令

node.js - 为什么 npm start 给我一个错误并且无法启动本地服务器?

python - 检查输入 : expected conv2d_1_input to have shape (50, 50, 1) 时出错,但得到形状为 (50, 50, 3) 的数组

django - pyodbc 在 heroku 服务器上安装错误命令 "gcc"失败,退出状态 1 - Django 项目

python - 根据一个列表对Python中的五个列表进行排序

pip - conda 相当于 pip install --user

python - 裤子:无法获得 lxml 分发 pip 要求

linux - 如何设置默认的 xrandr 模式

php - 希望在新的 Mac 上开始使用 Apache、PHP、MySQL、Python、Django

python - 通过仅索引最后一个轴的操作