2

I'm using the embedded python in Blender, which doesn't have matplotlib installed. I want to add it dynamically, to load it from my anaconda python installation. For that I inserted the anaconda site-packages to the beginning of the sys.path:

sys.path.insert(1, '/.../anaconda3/lib/python3.5/site-packages')

And I successfully imported matplotlib. But when I tried to import matplotlib.pyplot, I got this error:

File ".../anaconda3/lib/python3.5/site-packages/matplotlib/_path.py", line 6, in __bootstrap__
    imp.load_dynamic(__name__,__file__)
ImportError: numpy.core.multiarray failed to import

So I tried step by step to import numpy.core.multiarray. First, I imported numpy and numpy.core and both where from anaconda3 path.But when trying to import numpy.core.multiarray, it was imported from Blender's path! I even tried to remove the Blender's site-packages from the sys.path, but it didn't help.


EDIT

I think the problem is with imp.load_dynamic. The problem with numpy.core.multiarray was fixed when I called

imp.load_dynamic('numpy.core.multiarray', '.../anaconda3/lib/python3.5/site-packages/numpy/core/multiarray.cpython-35m-x86‌​_64-linux-gnu.so') 

Now I have a problem with _csv and libz... Something is telling me this isn't the best approach...

EDIT 2

I ended up installing matplotlib in Blender's enviroment using pip. It was a mess. If you are interested, these are the steps I needed to do.

2
  • 2
    matplotlib has a number of C extensions that expect to link against the versions of numpy and Python they were compiled with (i.e. you need ABI compatibility, not just API compatibility). You may be able to get things to work, but it's going to be fragile. Why not install matplotlib in Blender's embedded python environment? Commented Jan 12, 2016 at 21:16
  • Yes, this seems to be the way to go. I tried to make my Blender addon's installation as easy as it can be, but it seems the users will need to do it manually... Commented Jan 12, 2016 at 21:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.