1
$\begingroup$

For some of my python scrips i need additional modules like pytables. I followed the instructions here, but nothing worked for me:

  • first I set the PATH and PythonPath system vars to C:\Python34
  • then I tried to copy the module files from C:\Python34\Lib\site-packages to C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules, but when I try to import a module in the blender python console, it gave me an error (see below)
  • I deleted the C:\Program Files\Blender Foundation\Blender\2.74\python, but then in the blender system console it says: Warning: bundled python not found and is expected on this platform. <if you build with CMake: 'install' target max have not been build>

this error:

import tables 
Traceback (most recent call last):   File "<blender_console>", line 1, in <module>   File "C:\Program Files\Blender 
Foundation\Blender\2.74\scripts\modules\tables\__init__.py", line 25, in <module>
import numpy   File "C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\numpy\__init__.py", line 185, in <module>
from . import add_newdocs   File "C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc   File "C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\numpy\lib\__init__.py", line
8, in <module>
from .type_check import *   File "C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx   File "C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\numpy\core\__init__.py", line 6, in <module>
from . import multiarray ImportError: DLL load failed: %1 ist keine zulässige Win32-Anwendung.

I am using Win7 64bit version, python 3.42 and Blender 2.74.

I really don't know what I can still do to import these modules.

$\endgroup$

1 Answer 1

4
$\begingroup$

If you can start command prompt, and get python34 REPL, and import numpy and tables without errors, there's little reason that Blender's python console can't do the same.

Determine which python executable is used

Run this bit of code in two different locations. First from command prompt python interpreter and then from Blender's python console.

import sys
print(sys.path)
print(sys.executable)

You might notice that Blender isn't finding the same python executable. If they are different, this can explain why imports are failing. If they are the same that's a good thing. Half the battle is won!

Test your Python separately first.

On windows make sure the C:\Python34; is at the start of the PATH line, when you type in python into command prompt you'll want 3.4(.1+) to launch. (At least, I've had success with that and numpy1.8 on windows)

You should also be able to import numpy from command prompt without errors

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) <edited>
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> # also try the other important imports, stuff must work from here too

If you get errors from this python interpreter, forget about blender and fix the errors first. Once fixed, blender too will be able to use the libraries.

If you still have the python directory inside Blender's folder now is a good time to rename it to _python.

The Blender warning when you rename/remove its own python folder

Warning: bundled python not found and is expected on this platform.

is just that, a warning. Telling you that Blender looked in the directory where it keeps Python and couldn't find it, that's OK. It's perfectly fine to use your local Python34 installation, on windows I prefer to use it that way. Pasting around libraries into scripts/modules folder obviously didn't work, I suggest removing the files you added there to prevent them from interfering with imports.

For sverchok we found it was necessary to install Numpy 1.8 and Python3.4.1, and did a small write-up. I won't reproduce here because this is bordering on off-topic.

Forcing Blender to use your local system Python3.4.x

When Blender is forced to use the system's local python 3.4.x it hoists some paths of its own into the global namespace at runtime, to allow for importing bpy and all other blender modules. Apart from that the py3.4 runtime is entirely your system's.

If your imports are failing inside Blender, even though it uses the local python3.4, it is likely because you moved libraries into scripts/modules/.. or one of the other paths listed in sys.path. Python is going to look in the sequence given by sys.path, it iterates over the list, to find an import that matches your import statements. if Python finds anything before it hits 'C:\Python34\lib\site-packages` that will be tried first and only.

You should have a nice directory with all your python3.4 libraries like

C:\Python34\lib\site-packages\numpy
C:\Python34\lib\site-packages\scipy
# etc
$\endgroup$
4
  • $\begingroup$ i did exactly this. when i start python from cmd and import modules, it does perfectly work. after renaming the C:\Program Files\Blender Foundation\Blender\2.74\python folder it only shows me the error above and i can't import numpy or tables. if i call sys.path in blender, it shows first this, following with my C:\Python34 paths: ['C:\\Program Files\\Blender Foundation\\Blender\\2.74\\scripts\\addons', 'C:\\Program Files\\Blender Foundation\\Blender\\2.74\\scripts\\startup', 'C:\\Program Files\\Blender Foundation\\Blender\\2.74\\scripts\\modules', ... $\endgroup$
    – vtni
    May 6, 2015 at 22:29
  • $\begingroup$ what about stackoverflow.com/questions/5927633/… sys.executable and help(sys). $\endgroup$
    – zeffii
    May 6, 2015 at 22:39
  • $\begingroup$ in Blender's python console: 'C:\\Program Files\\Blender Foundation\\Blender\\blender-app.exe' and in cmd: 'C:\\Python34\\python.exe', the log of help(sys) from blender i posted here: pastebin.com/2uQrvzxX $\endgroup$
    – vtni
    May 6, 2015 at 22:56
  • $\begingroup$ I will update my answer. $\endgroup$
    – zeffii
    May 7, 2015 at 4:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .