Python.h error

Hi all,

i try to generate a “snap” of my Glances monitoring software.

The Snap file is here: https://github.com/nicolargo/glances/blob/develop/snap/snapcraft.yaml

When i run the Snapcraft command, i have the following error:

Skipping pull bottle (already ran)
Skipping pull docker (already ran)
Skipping pull glances (already ran)
Skipping build bottle (already ran)
Skipping build docker (already ran)
Building glances 
Looking in links: /home/nicolargo/tmp/glances/parts/glances/python-packages
Processing /home/nicolargo/tmp/glances/parts/glances/build
Collecting psutil>=5.3.0 (from Glances==3.1.1b0)
Building wheels for collected packages: Glances, psutil
  Running setup.py bdist_wheel for Glances ... done
  Stored in directory: /tmp/tmpp_h395p8
  Running setup.py bdist_wheel for psutil ... error
  Complete output from command /home/nicolargo/tmp/glances/parts/glances/install/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-wheel-284o7l29/psutil/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/pip-wheel-kn_8g9ey:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/psutil
  copying psutil/_compat.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_psposix.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_pslinux.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_psosx.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/__init__.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_pssunos.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_exceptions.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_common.py -> build/lib.linux-x86_64-3.6/psutil
  copying psutil/_psaix.py -> build/lib.linux-x86_64-3.6/psutil
  creating build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_system.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_process.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/__main__.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/__init__.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-3.6/psutil/tests
  copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-3.6/psutil/tests
  running build_ext
  building 'psutil._psutil_linux' extension
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/psutil
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -I/usr/include/python3.6 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=548 -DPSUTIL_LINUX=1 -I/home/nicolargo/tmp/glances/parts/glances/install/usr/include/python3.6m -c psutil/_psutil_common.c -o build/temp.linux-x86_64-3.6/psutil/_psutil_common.o
  psutil/_psutil_common.c:9:10: fatal error: Python.h: No such file or directory
   #include <Python.h>
            ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for psutil
  Running setup.py clean for psutil
Successfully built Glances
Failed to build psutil
ERROR: Failed to build one or more wheels
Failed to run '/home/nicolargo/tmp/glances/parts/glances/install/usr/bin/python3 -m pip wheel --no-index --find-links /home/nicolargo/tmp/glances/parts/glances/python-packages --wheel-dir /tmp/tmpp_h395p8 .': Exited with code 1.

I do not understand because Python dev is installed for both Python 2 and 3 on my Ubuntu system:

$ locate Python.h
/usr/include/python2.7/Python.h
/usr/include/python3.6m/Python.h

Any idea ?

Thanks !

We ran into the same issue. There’s a bug filed for it, and if you look there you can see how to work around it until it’s fixed.

https://bugs.launchpad.net/snapcraft/+bug/1802345

3 Likes

I just built your snap without encountering such error, can you reproduce the issue now?

I thought the problem was with me.