SofaPython3
SofaPython3 copied to clipboard
Import numpy error while opening .py file
Hello! I am using the SOFA_v24.06.00_MacOS binaries with python3.10
I am trying to get started using the SofaPython3 plugin but I am facing some errors. I run RunSofa and I get no problem; SofaPython3 loads correctly.
As a simple test, when I load into runSofa a simple python script with only "import numpy" I get the following error:
[DEPRECATED] [SofaPython3::SceneLoader] Unable to completely load the scene from file '/Users/digitalsurgerylab/Downloads/test.py'.
Python exception:
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
At:
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/__init__.py(135): <module>
<frozen importlib._bootstrap>(241): _call_with_frames_removed
<frozen importlib._bootstrap_external>(883): exec_module
<frozen importlib._bootstrap>(703): _load_unlocked
<frozen importlib._bootstrap>(1006): _find_and_load_unlocked
<frozen importlib._bootstrap>(1027): _find_and_load
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scipy/__init__.py(47): <module>
<frozen importlib._bootstrap>(241): _call_with_frames_removed
<frozen importlib._bootstrap_external>(883): exec_module
<frozen importlib._bootstrap>(703): _load_unlocked
<frozen importlib._bootstrap>(1006): _find_and_load_unlocked
<frozen importlib._bootstrap>(1027): _find_and_load
/Users/digitalsurgerylab/Downloads/test.py(12): <module>
<frozen importlib._bootstrap>(241): _call_with_frames_removed
<frozen importlib._bootstrap_external>(883): exec_module
<string>(6): <module>
Any help fixing this would be greatly appreciated! Cheers
This seems to be an issue with Apple Silicon CPUs.
To resolve this issue, I opted to enforce the installation of the x86_64 architecture when installing numpy and scipy using pip. This ensured that the modules consistently imported the correct x86_64 architecture instead of ARM.
arch -x86_64 pip install numpy==1.26.0 scipy
Thank you AlexandreLaborde, it works!