Ubuntu, fatal error: Python.h: No such file or directory #include <Python.h>

Question:

When I try to install psycopg2 the error appears

fatal error: Python.h: No such file or directory
      #include <Python.h>

Because, there is a search for this file along the path /usr/include/python3.8

But this file is located in the path /usr/local/include/python3.8/Python.x

How to solve this problem?? Is Python installed in the wrong directory?

Asked By: Mr How

||

Answers:

Its not clear what version of Ubuntu you are using. Assuming it is a fresh install and you don’t have these installed. I would suggest you install the following

sudo apt-get install python3 python-dev python3-dev build-essential

Once these are installed then try again installing psycopg2

Answered By: Ritwik Tiwari
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.