[Ubuntu] Fix error “Fatal error: Python.h: No such file or Directory” when using pip

29

When you want to install an application or build a module for specific python version by command ‘pip‘ on OS Ubuntu/Debian. You are not lucky when have to encounter the error “Fatal error: Python.h: No such file or Directory” like example below :

You will consider what is ‘Python.h‘ and search google for finding the resolution to handle this case. So we will go to next part, how to fix this error.

Fix error “fatal error: Python.h: No such file or Directory”

Python.h is just a header file, be used by ‘gcc‘ application to build application/module for a lot of program like Python. So you have to install package named ‘python-dev‘. This package includes many header files, static files and neccessary development tools to build module Python, extend Python interpreter,… Ok, we will install ‘python-dev‘ with these step:

+ Python version 2.x+

+ Python version 3.x+

 
Example, output installing ‘python-dev’ :

Now recheck the process installing 3rd party module/application for Python by using pip command. You will see the error ‘Fatal error: Python.h: No such file or Directory’ has gone. Good luck !

LEAVE A REPLY