cairo/device.c:30:10: fatal error: Python.h: No such file or directory [SOLVED]
Answered
When trying to upgrade all my packages in PyCharm some of them failed. One of them was pygobject. Here are the most important details:
Executed command:
pip install -U pygobject==3.34.0
(Small part of) Command output:
cairo/device.c:30:10: fatal error: Python.h: No such file or directory
#include <Python.h>
Proposed solution:
Make sure that you have installed Python development packages for your operating system.
But when I run "sudo apt-get install python-dev python-pip" in Terminal (on Ubuntu 18.04.3 LTS) I get this 'no problem'-message:
henrik@Henrik-L570:~$ sudo apt-get install python-dev python-pip
[sudo] password for henrik:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-dev is already the newest version (2.7.15~rc1-1).
python-pip is already the newest version (9.0.1-2.3~ubuntu1.18.04.1).
The following packages were automatically installed and are no longer required:
libclamav7 libllvm6.0 libllvm7
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Can anyone please help me. Thank you.
Please sign in to leave a comment.
Addition:
A complete search of my PC for 'python.h' finds this:
Have you tried just sudo apt-get install python3-dev (or sudo apt-get install python-dev depending on the version)?
The issue doesn't seem to be PyCharm specific after all.
Thank you VERY much! That solved it. As you can see above, I installed the wrong 'python-dev'-version.
Now only ONE package fail to upgrade:
PyCharm suggests running it from Terminal:
" Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '/mnt/4AF15A0435E762B4/DataDoc/OneDrive/PycharmProjects/python3/venv/bin/python'. "
But I still get an error. This is the output from Terminal:
PLEASE help!
Thank you.
PS: There is no 'cups.h' file on my Ubuntu PC.
I found the solution here:
How to upgrade all Python packages in Kali Linux - https://miloserdov.org/?p=2723 :
The cups/cups.h file is missing, this file is in the libcups2-dev package, install it:
sudo
apt
install
libcups2-dev
Most of the time these are dependency-issues. Python.h is used by GNU Compiler Collection (gcc) to build applications. You need to install a package called python-dev for building Python modules, extending the Python interpreter or embedding Python in applications. 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.
Reason for this error:
How to solve this error: