Solved Blender, ImportError: No module named numpy, default version python

Hi all,

When in blender, I try to load an addon using numpy or to import numpy in the blender's console, and I get the following error :
Code:
ImportError: No module named numpy

But numpy was installed with blender.
Code:
pkg info | grep numpy
py27-numpy-1.11.0,1            The New Numeric Extension to Python

I found the answer by myself but that was quite long so I post it here.
 
Numpy is installed but compiled with the FreeBSD default python version: 2.7; And blender needs 3.4. I read somewhere that blender is shipped with numpy. This is not true, at least on FreeBSD. I got the same error in a console than in blender:
Code:
% python3.4
Python 3.4.4 (default, Apr  5 2016, 05:21:25)
[GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)] on freebsd10
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
...
ImportError: No module named numpy

I found more specifically these resources :
1. http://stackoverflow.com/questions/9349831/how-to-set-python-version-by-default-in-freebsd
2. http://blender.stackexchange.com/questions/5737/no-module-called-numpy

I used the first one. Here is how I can build numpy with python 3.4 and keep the default FreeBSD python version.

Code:
# Change the default python version to 3.4

rm /usr/local/bin/python
ln -s /usr/local/bin/python3.4 /usr/local/bin/python

# py34-setuptools34 will be installed but conflicts with py27-setuptools27

pkg delete -f py27-setuptools27-20.0

# Finally

portmaster py27-numpy
...
Re-install py27-numpy-1.11.0,1
Install devel/py-setuptools34
y

Now it works! But I want to keep the FreeBSD default python version, because I tested a few years ago and it was a very bad idea to change it…

Code:
rm /usr/local/bin/python
ln -s /usr/local/bin/python2.7 /usr/local/bin/python
pkg delete -f py34-setuptools34
portmaster devel/py-setuptools

Done!

NB:
Setting DEFAULT_VERSIONS=python=3.4 python3=3.4 python2=2.7 in /etc/make.conf doesn't work. I think you must recompile python- and python3. To be confirmed…
 
Back
Top