Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import numpy error while opening .py file #460

Open
fgmelo14 opened this issue Oct 1, 2024 · 2 comments
Open

Import numpy error while opening .py file #460

fgmelo14 opened this issue Oct 1, 2024 · 2 comments

Comments

@fgmelo14
Copy link

fgmelo14 commented Oct 1, 2024

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

@AlexandreLaborde
Copy link

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

@fgmelo14
Copy link
Author

fgmelo14 commented Oct 3, 2024

Thank you AlexandreLaborde, it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants