猿问

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

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


手掌心
浏览 385回答 3
3回答

12345678_0001

WSL 与该问题无关,这是一个相当标准的错误。确保安装了以下软件包。使用apt-get install packagename. 此特定时间的问题已通过安装python-dev.python3python3-pipipython3build-essentialpython-devpython3-dev作为单个命令:sudo apt-get install python3 python3-pip ipython3 build-essential python-dev python3-dev

守着一只汪

我在 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 /includelibpython2.7-dbg: /usr/include/python2.7_d/Python.hlibpython2.7-dev: /usr/include/python2.7/Python.hlibpython3.5-dbg: /usr/include/python3.5dm/Python.hlibpython3.5-dev: /usr/include/python3.5m/Python.hpypy-dev: /usr/lib/pypy/include/Python.h然后对我需要哪个包进行了有根据的猜测。忽略Python2,忽略调试(dbg),忽略pypy,从而留下libpython3.5-dev。
随时随地看视频慕课网APP

相关分类

Python
我要回答