17 November 2018 at 17 h 09 min #12500
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>
and it causes this error:
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, try
git 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?
Zahra17 June 2019 at 15 h 45 min #13733
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>
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:
the input mesh files:
Thanks for any help.
Zahra24 August 2019 at 15 h 46 min #14156
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.
- You must be logged in to reply to this topic.