Home › Forum › SOFA › Programming with SOFA › [SOLVED] numpy error: cannot import name multiarray
Tagged: 64_bits, Linux_ubuntu, SOFA_1706
- This topic has 2 replies, 1 voice, and was last updated 5 years, 2 months ago by Zahra.
-
AuthorPosts
-
17 November 2018 at 17:09 #12500ZahraBlocked
Hi,
I am using Spyder in anaconda2 to write a part of my code and then run the .py file using runSofa. It worked properly before, but recently I needed to import numpy:
import numpy as np
File “/home/zahra/anaconda2/lib/python2.7/site-packages/numpy/__init__.py”, line 142, in <module>
from . import add_newdocs
File “/home/zahra/anaconda2/lib/python2.7/site-packages/numpy/add_newdocs.py”, line 13, in <module>
from numpy.lib import add_newdoc
File “/home/zahra/anaconda2/lib/python2.7/site-packages/numpy/lib/__init__.py”, line 8, in <module>
from .type_check import *
File “/home/zahra/anaconda2/lib/python2.7/site-packages/numpy/lib/type_check.py”, line 11, in <module>
import numpy.core.numeric as _nx
File “/home/zahra/anaconda2/lib/python2.7/site-packages/numpy/core/__init__.py”, line 26, in <module>
raise ImportError(msg)and it causes this error:
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you’re working with a numpy git repo, trygit clean -xdf
(removes all
files not under version control). Otherwise reinstall numpy.Original error was: cannot import name multiarray
I tried many instructions I found on the web (reinstalling numpy, etc.) but it did not work. When I uninstall anaconda and just use this instruction:
sudo apt-get install python2.7-dev python-numpy python-scipy
the .py file works properly.
Does anyone know how I can fix this problem?
Best,
Zahra17 June 2019 at 15:45 #13733ZahraBlockedHi again!
I still have a big challenge with this problem. I appreciate if anyone can help me to fix this.
When I import numpy in a python file, it works with no error. But when I import numpy in a Scene controller, I receive the following error:ImportError: cannot import name _distributor_init
File “/home/zahra/sofa/Work/test/AttachLiverSurface_controller.py”, line 18, in <module>
import numpy
File “/home/zahra/anaconda2/lib/python2.7/site-packages/numpy/__init__.py”, line 140, in <module>
from . import _distributor_init[ERROR] [SofaPython] Script (file:AttachLiverSurface_controller) import error
[ERROR] [PythonScriptController(PythonScriptController)] load error (file ‘/home/zahra/sofa/Work/test/AttachLiverSurface_controller.py’ not parsable)The python scene and the controller are accessible here:
The main python file:
https://gist.github.com/zbounik/fa61c74209a6dbc85cacbe170f9f17b5the controller:
https://gist.github.com/zbounik/569971d696522a2b5b4088888a535dd0the input mesh files:
https://gist.github.com/zbounik/0525820bbe52a9b74b421d3785048259Thanks for any help.
Best,
Zahra24 August 2019 at 15:46 #14156ZahraBlockedHi,
My problem with importing numpy has been solved. In my case, the problem was that the default python in my system wasn’t the one that SOFA is using. Changing the default python fixed the error.Best,
Zahra -
AuthorPosts
- You must be logged in to reply to this topic.