Ubuntu – How to install regex package for python 3.4 without errors

pythonregex

I have a little problem (or a big one?). I want to install regex package
for Python 3.4. But then I use pip or our installation methods I am getting error:

universe@universe-AOD270:~/Downloads/regex-2016.04.25$ python setup.py
install --user
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying Python2/regex.py -> build/lib.linux-x86_64-2.7
copying Python2/_regex_core.py -> build/lib.linux-x86_64-2.7
copying Python2/test_regex.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_regex' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/Python2
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c Python2/_regex.c -o build/temp.linux-x86_64-2.7/Python2/_regex.o
****Python2/_regex.c:46:20: fatal error: Python.h: No such file or directory
compilation terminated.****
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I think that this problem arise because installer try to install this package into Python2.7 directory, but I am not sure. I try pip installation, launch from interpreter of Python, running through terminal, but have no success.
Please, help me to solve this problem. Thanks in advance.

Best Answer

I also struggle with this error, then I found the python3-dev is missing but when I run the command it's already installed. Then I check for which python version it is installed using below command -

sudo find / -name "Python.h"

and output is like -

python2.7/Python.h
python3.5/Python.h

So then I check the version of python I am running to install that package using below command

python3 -V

Output -

Python 3.6.7

So to install python3-dev use below command

sudo apt-get install python3.6-dev 

Just replace it with your python3 or python2 version