Python headers for python3 not found

> sh compile_python3.5_unix.sh Compiling python (swig) wrapper...
matlabnoise_wrap.cxx:173:21: fatal error: Python.h: No such file or directory
 # include <Python.h>

I’m trying to compile Matlabnoise which relies on python3, but I’m getting the error that Python.h is not found. I think I must have installed every python package there is. Notice in particular python3-devel which I would think should provide Python.h. A manual search for the file reveals that it’s present in “/usr/include/python2.7” and “/usr/include/python3.5m”. I’m not entirely sure why the python3 directory has an ‘m’ postfix or why the C-compiler (?) can’t find it.


torstein@torstein-pc:~/progs/matlabnoise> rpm -qa --last | grep python
python-setuptools-28.3.0-2.1.noarch           Tue 14 Feb 2017 01:51:40 PM CET
python-imobiledevice-1.2.0+git20170122.45fda81-2.1.x86_64 Tue 14 Feb 2017 01:51:28 PM CET
python-plist-1.12+git20170119.6a44dfb-2.1.x86_64 Tue 14 Feb 2017 01:51:26 PM CET
python3-urllib3-1.19.1-1.2.noarch             Wed 08 Feb 2017 04:06:14 PM CET
python3-CXX-6.2.5-4.3.noarch                  Wed 08 Feb 2017 03:55:55 PM CET
python3-devel-3.5.1-3.6.x86_64                Wed 08 Feb 2017 03:36:10 PM CET
python-opengl-accelerate-3.1.0-3.8.x86_64     Wed 08 Feb 2017 02:29:23 PM CET
python-opengl-3.1.0-3.3.noarch                Wed 08 Feb 2017 02:29:23 PM CET
python3-opengl-3.1.0-5.1.noarch               Wed 08 Feb 2017 02:15:24 PM CET
python3-numpy-1.12.0-1.1.x86_64               Wed 08 Feb 2017 02:15:23 PM CET
python-qt5-utils-5.7.1-1.2.x86_64             Wed 08 Feb 2017 01:50:07 PM CET
python-qt5-5.7.1-1.2.x86_64                   Wed 08 Feb 2017 01:50:07 PM CET
python-six-1.10.0-3.3.noarch                  Mon 06 Feb 2017 12:06:20 PM CET
python-pip-9.0.1-1.1.noarch                   Mon 06 Feb 2017 12:06:20 PM CET
python-xml-2.7.13-1.2.x86_64                  Mon 06 Feb 2017 10:10:59 AM CET
python-numpy-1.12.0-1.2.x86_64                Mon 06 Feb 2017 10:10:59 AM CET
python-devel-2.7.13-1.2.x86_64                Mon 06 Feb 2017 10:10:59 AM CET
python-base-2.7.13-1.2.x86_64                 Mon 06 Feb 2017 10:10:56 AM CET
libpython2_7-1_0-2.7.13-1.2.x86_64            Mon 06 Feb 2017 10:10:49 AM CET
python-smbc-1.0.15.5-1.1.x86_64               Wed 25 Jan 2017 12:26:18 AM CET
python-gtk-2.24.0-15.8.x86_64                 Wed 25 Jan 2017 12:26:11 AM CET
python-gobject-Gdk-3.22.0-1.1.x86_64          Wed 25 Jan 2017 12:24:53 AM CET
python3-cupshelpers-1.5.7-9.3.noarch          Wed 25 Jan 2017 12:24:53 AM CET
python3-gobject-Gdk-3.22.0-1.1.x86_64         Wed 25 Jan 2017 12:24:51 AM CET
python3-pycurl-7.43.0-3.4.x86_64              Wed 25 Jan 2017 12:24:32 AM CET
python-qt4-4.12-1.2.x86_64                    Wed 25 Jan 2017 12:24:25 AM CET
python-atspi-2.20.3-1.1.noarch                Wed 25 Jan 2017 12:24:23 AM CET
python-gobject-cairo-3.22.0-1.1.x86_64        Wed 25 Jan 2017 12:24:22 AM CET
python3-gobject-cairo-3.22.0-1.1.x86_64       Wed 25 Jan 2017 12:24:22 AM CET
python-gobject-3.22.0-1.1.x86_64              Wed 25 Jan 2017 12:24:21 AM CET
python3-gobject-3.22.0-1.1.x86_64             Wed 25 Jan 2017 12:24:21 AM CET
dbus-1-python-1.2.0-6.13.x86_64               Wed 25 Jan 2017 12:24:21 AM CET
python-pam-0.5.0-90.7.x86_64                  Wed 25 Jan 2017 12:24:20 AM CET
python3-smbc-1.0.15.6-1.2.x86_64              Wed 25 Jan 2017 12:24:19 AM CET
dbus-1-python3-1.2.0-6.13.x86_64              Wed 25 Jan 2017 12:24:14 AM CET
zypp-plugin-python-0.5-1.3.x86_64             Wed 25 Jan 2017 12:24:11 AM CET
python-talloc-2.1.8-1.1.x86_64                Wed 25 Jan 2017 12:24:11 AM CET
python-pyinotify-0.9.6-1.2.noarch             Wed 25 Jan 2017 12:24:11 AM CET
python-ptyprocess-0.5.1-1.1.noarch            Wed 25 Jan 2017 12:24:11 AM CET
python-Pillow-3.1.1-4.1.x86_64                Wed 25 Jan 2017 12:24:11 AM CET
python-pexpect-4.2.1-1.1.noarch               Wed 25 Jan 2017 12:24:11 AM CET
python-sip-4.19-1.1.x86_64                    Wed 25 Jan 2017 12:24:05 AM CET
python-Cython-0.25.1-1.1.x86_64               Wed 25 Jan 2017 12:24:05 AM CET
python-gobject2-2.28.6-26.10.x86_64           Wed 25 Jan 2017 12:24:04 AM CET
python-cairo-1.10.0-15.8.x86_64               Wed 25 Jan 2017 12:24:04 AM CET
python-2.7.13-1.2.x86_64                      Wed 25 Jan 2017 12:24:04 AM CET
python-rpm-macros-1.0git.1483874658.ead0b0b-1.1.noarch Wed 25 Jan 2017 12:24:03 AM CET
python3-cups-1.9.72-1.7.x86_64                Wed 25 Jan 2017 12:23:59 AM CET
python3-requests-2.11.1-1.2.noarch            Wed 25 Jan 2017 12:23:47 AM CET
python3-wheel-0.29.0-3.2.noarch               Wed 25 Jan 2017 12:23:43 AM CET
python3-chardet-2.3.0-1.5.noarch              Wed 25 Jan 2017 12:23:43 AM CET
python3-gedit-3.22.0-2.3.x86_64               Wed 25 Jan 2017 12:23:42 AM CET
libboost_python3-1_62_0-1.62.0-2.1.x86_64     Wed 25 Jan 2017 12:23:26 AM CET
python3-xlib-0.15-1.3.noarch                  Wed 25 Jan 2017 12:23:24 AM CET
python3-setproctitle-1.1.10-1.4.x86_64        Wed 25 Jan 2017 12:23:24 AM CET
python3-py-1.4.32-1.1.noarch                  Wed 25 Jan 2017 12:23:24 AM CET
python3-cairo-1.10.1~git20121222.5a45b0b-1.1.x86_64 Wed 25 Jan 2017 12:23:21 AM CET
python3-base-3.5.1-3.6.x86_64                 Wed 25 Jan 2017 12:23:10 AM CET
python3-3.5.1-3.8.x86_64                      Wed 25 Jan 2017 12:23:10 AM CET
libpython3_5m1_0-3.5.1-3.6.x86_64             Wed 25 Jan 2017 12:22:53 AM CET



Headers are generally in the devel packages. You seem to only have the runtime packages

Isn’t python3-devel-3.5.1-3.6.x86_64 the devel package?

OOP’s missed that one in the list

But that’s for python 2 not 3

No – python-devel-2.7.13-1.2.x86_64 ​is for python 2

Hi
Do you have a download link to the source?

No, it’s downloaded either through the standard repos (if available there) or through searching opensuse.pkgs.org and using the one-click installer.
Either way it shouldn’t matter as the program I’m trying to compile relies on python3 not python2. Python3 devel also originate either from standard repos or online official repos.

Is there any way I can find the source, or do you want me to install python3 devel from another source?

Hi
No, I meant the matlabnoise, anyway I’m guessing it’s the one on GitHub…

Edit the script and add an m on the include line…


#!/bin/bash
echo "Compiling python (swig) wrapper..."
swig -c++ -python -modern -py3 matlabnoise.i
g++ -fpic -c vec2.cpp vec3.cpp vec4.cpp noise_common.cpp matlabnoise_wrap.cxx \
    -I/usr/local/include \
    -I/usr/include/python3.5m
g++ -shared vec2.o vec3.o vec4.o noise_common.o matlabnoise_wrap.o \
    -o _matlabnoise.so 
echo "Add done!"

Then run again;


./compile_python3.5_unix.sh 
Compiling python (swig) wrapper...
Add done!

ls *.so
_matlabnoise.so

I don’t know why that ‘m’ postfix is there, but it shouldn’t matter at all to the compiler.
Actually the compiler wouldn’t look in /usr/include/python3.5/ either, you (or the build files of the source that you compile) need to tell the compiler to look there (via the -I switch).

The problem here seems to be that Matlabnoise doesn’t pass the proper arguments to the compiler so that it actually would look in /usr/include/python3.5m/" for include files too…
(it should use something like “pkg-config --cflags python3” to get the necessary compiler flags, but apparently doesn’t)

Try to add the include directory manually via something like:

export CXXFLAGS=`pkg-config --cflags python3`

or modify the Makefiles or that build script accordingly.

Adding an ‘m’ to the build script (compile_python3.5_unix.sh) did the trick; thank you all.