4

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.

  • 5
    Just install python-dev and python3-dev. Although does Python not have a built-in re module? – UniversallyUniqueID Apr 26 '16 at 12:20
  • Just to be clear, you are not talking about the built-in regex (re) module, right? – don.joey Apr 27 '16 at 7:23
  • There is a regex package as well that mostly difference by being non-greedy by default (if I recall correctly). – don.joey Apr 27 '16 at 7:24
  • to don.joy - I need regex package because it has in finditer() overlapped flags, finditer() in re modul doesn't have such options. I am taking about a separate package 'regex-2016.04.25'. – Богдан Іващук Apr 27 '16 at 10:46
0

It's because of you didn't have python-dev or python3-dev packages due to your python versoin.

Just install them through 'pip' or 'pip3' package installer and enjoy it!

Note if you find the mentioned packages is installed and your problem is still exist!, you must look for 'Python.h' file in your file system by:

sudo find / -name "Python.h"

and then add listed paths which includes Python.h into your C_INCLUDE_PATH environment variable something like:

export C_INCLUDE_PATH=/usr/include/python3.6m/

and now retry your installation and enjoy!

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.