Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

psycopg: Python.h: No such file or directory

I'm compiling psycopg2 and get the following error: Python.h: No such file or directory

How to compile it, Ubuntu12 x64.

like image 301
user2957539 Avatar asked Nov 07 '13 18:11

user2957539


People also ask

How do I fix Python H No such file or directory?

You encounter "Python. h: No such file or directory" error while trying to build a shared library using the file extension of another language ( e.g. 'C' ). If you are trying to build a shared library using the file extension of another language, you need to install the correct development version of Python.

What is Python H?

Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications.


2 Answers

Python 2:

sudo apt-get install python-dev 

Python 3:

sudo apt-get install python3-dev 
like image 162
Michal Avatar answered Oct 16 '22 17:10

Michal


This is a dependency issue.

I resolved this issue on Ubuntu using apt-get. Substitute it with a package manager appropriate to your system.

For any current Python version:

sudo apt-get install python-dev 

For alternative Python version:

sudo apt-get install python<version>-dev 

For example 3.5 as alternative:

sudo apt-get install python3.5-dev 
like image 39
I159 Avatar answered Oct 16 '22 17:10

I159