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.
52 Answers
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.hSo then I check the version of python I am running to install that package using below command
python3 -VOutput -
Python 3.6.7So to install python3-dev use below command
sudo apt-get install python3.6-dev Just replace it with your python3 or python2 version
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!