Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Failed building wheel for regex" while installing pip package

I am having issues installing a pip package on Windows 10 WSL running Debian Stretch.

While running sudo pip install invoice2data, with python3-pip installed I run into following errors.

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/
like image 257
Sašo Avatar asked Dec 12 '18 13:12

Sašo


2 Answers

WSL is unrelated to the issue, this is a fairly standard error.

Ensure the following packages are installed. Install them using apt-get install packagename. The issue this particular time was resolved by installing python-dev.

python3
python3-pip
ipython3
build-essential
python-dev
python3-dev

As a single command:

sudo apt-get install python3 python3-pip ipython3 build-essential python-dev python3-dev
like image 73
Sašo Avatar answered Nov 15 '22 21:11

Sašo


Had a similar error while running pip3 install pyinquirer

ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a7ojseph/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a7ojseph/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-bodowot9/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/regex Check the logs for full command output.

Installing python3-dev didn't work for me, as I already had it installed. However installing build-essential did the trick and the regex module installed successfully.

like image 20
Hristiyan Andreev Avatar answered Nov 15 '22 20:11

Hristiyan Andreev