为了账号安全,请及时绑定邮箱和手机立即绑定

安装 pip 包时“正则表达式的构建轮失败”

安装 pip 包时“正则表达式的构建轮失败”

手掌心 2021-09-14 20:52:03
我在运行 Debian Stretch 的 Windows 10 WSL 上安装 pip 包时遇到问题。在运行时sudo pip install invoice2data,python3-pip安装后我遇到了以下错误。error: command 'x86_64-linux-gnu-gcc' failed with exit status 1----------------------------------------Failed building wheel for regexRunning setup.py clean for regexFailed to build regexx86_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.oregex_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/
查看完整描述

3 回答

?
12345678_0001

TA贡献1802条经验 获得超5个赞

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


查看完整回答
反对 回复 2021-09-14
?
守着一只汪

TA贡献1872条经验 获得超3个赞

我在 Ubuntu 上运行 Python 3.5。我是如何安装regexPython 包的:


$ sudo apt-get install libpython3.5-dev

$ pip3 install regex --no-use-wheel

背景研究详情:


我Python.h通过使用apt-file来定位它来确定提供丢失文件的包名称。


# install the apt-file package in case you don't have it

$ sudo apt-get install apt-file


# populate/refresh the local apt-file package data

$ sudo apt-file update


# search for /Python.h.  Since it's a C header file,

# I also grep for /include to limit the results.

$ sudo apt-file search /Python.h | grep /include

libpython2.7-dbg: /usr/include/python2.7_d/Python.h

libpython2.7-dev: /usr/include/python2.7/Python.h

libpython3.5-dbg: /usr/include/python3.5dm/Python.h

libpython3.5-dev: /usr/include/python3.5m/Python.h

pypy-dev: /usr/lib/pypy/include/Python.h

然后对我需要哪个包进行了有根据的猜测。忽略Python2,忽略调试(dbg),忽略pypy,从而留下libpython3.5-dev。


查看完整回答
反对 回复 2021-09-14
  • 3 回答
  • 0 关注
  • 384 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信