5
$\begingroup$

I'm compiling an external C package for my Blender 2.78a Python 3.5.

My compiling script looks like

from distutils.core import setup, Extension
import numpy
setup(name='_tifffile', ext_modules=[Extension('_tifffile', ['tifffile.c'], include_dirs=[n
umpy.get_include()])])

Upon running it, I got

tifffile.c:71:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.
error: command 'gcc' failed with exit status 1

I looked into /blender-2.78a-linux-glibc211-x86_64/2.78/python/include/python3.5m/ and indeed didn't see Python.h.

In general Python community, people suggest simply uninstalling the current Python and reinstalling the dev version. I don't wanna hack the Python bundled with Blender like that.

How can I solve this problem?

$\endgroup$
  • $\begingroup$ I realize this is actually a frequently occurring problem. In the past 10 days, while I was using Blender Python's pip to install modules, I had this problem twice. $\endgroup$ – Sibbs Gambling Jul 25 '17 at 20:11
3
$\begingroup$

First, if you install blender with your linux distro, then a proper installation of python3 and blender with your particular distro should solve your problem.

e.g. for debian:

  1. sudo apt-get install python3 python3-dev
  2. sudo apt-get install blender

Second, if you really want to install the python header files for the python that runs inside blender, then you can do it the following way:

Find out the exact blender python version:

  1. /path/to/blender-2.78a-linux-glibc211-x86_64/2.78/python/bin/python3.5m -V

Download and install the python header files from the official python homepage:

  1. point your browser at https://www.python.org/downloads/source/
  2. download Gzipped source tarball from the exact same python version as your blender python version
  3. cd ~/Downloads/
  4. tar -xzf Python-3.X.X.tgz
  5. cp Python-3.X.X/Include/* /path/to/blender-2.78a-linux-glibc211-x86_64/2.78/python/include/python3.5m/

That should get you rolling. Best, Bue

| improve this answer | |
$\endgroup$
0
$\begingroup$

You have to install the Python development package. In Ubuntu is python3-dev (if you are using Python3). So:

sudo apt install python3-dev

| improve this answer | |
$\endgroup$
  • $\begingroup$ I'm talking about the python bundled with Blender. $\endgroup$ – Sibbs Gambling Aug 1 '17 at 19:33
  • $\begingroup$ Have you tried to install the version of Python you need with dev tools in a custom directory and make the Blender path to point to it then? I don't see how the Python version bundled with Blender can be different from the standard library, assuming they are the same version $\endgroup$ – lorenzoastrosat Aug 2 '17 at 9:15
  • $\begingroup$ How does one " make the Blender path to point to it"? It would be great if this actually is possible. Thanks $\endgroup$ – Sibbs Gambling Aug 3 '17 at 21:42
  • $\begingroup$ Try set environment variables properly: blender.org/forum/viewtopic.php?t=25657 $\endgroup$ – lorenzoastrosat Aug 4 '17 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.