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.

0
5 comments

Addition:

A complete search of my PC for 'python.h' finds this:

 

0

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.

0

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:

pip install -U pycups==1.9.74

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:

henrik@Henrik-L570:/mnt/4AF15A0435E762B4/DataDoc/OneDrive/PycharmProjects/python3/venv/bin$ pip install -U pycups==1.9.74
Collecting pycups==1.9.74
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/00/ce/836a0deb8b24bcd5f850f8fb97f99fb4abd7374e078b9e6df5a0838f8eb5/pycups-1.9.74.tar.bz2 (52kB)
100% |████████████████████████████████| 61kB 10.9MB/s
Building wheels for collected packages: pycups
Running setup.py bdist_wheel for pycups ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EIDpaI/pycups/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpAEjyyKpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
building 'cups' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DVERSION="1.9.74" -I/usr/include/python2.7 -c cupsmodule.c -o build/temp.linux-x86_64-2.7/cupsmodule.o
cupsmodule.c:23:10: fatal error: cups/cups.h: No such file or directory
#include <cups/cups.h>
^~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Failed building wheel for pycups
Running setup.py clean for pycups
Failed to build pycups
Installing collected packages: pycups
Running setup.py install for pycups ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EIDpaI/pycups/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-QaP0zb-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
running install
running build
running build_ext
building 'cups' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DVERSION="1.9.74" -I/usr/include/python2.7 -c cupsmodule.c -o build/temp.linux-x86_64-2.7/cupsmodule.o
cupsmodule.c:23:10: fatal error: cups/cups.h: No such file or directory
#include <cups/cups.h>
^~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EIDpaI/pycups/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-QaP0zb-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-EIDpaI/pycups/
henrik@Henrik-L570:/mnt/4AF15A0435E762B4/DataDoc/OneDrive/PycharmProjects/python3/venv/bin$

PLEASE help!

Thank you.

PS: There is no 'cups.h' file on my Ubuntu PC.

 

0

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

 

0

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:

  • You haven't properly installed the header files and static libraries for python dev.
  • Also, sometimes include files might not be default in the include path.

How to solve this error:

  • Install the missing files and libraries.
  • Include Path and Library.
  • Finally, Compile it.

 

0

Please sign in to leave a comment.