OpenSim API Python Import Error: Library not loaded

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
P Wesberg
Posts: 2
Joined: Fri Jan 11, 2019 5:55 am

OpenSim API Python Import Error: Library not loaded

Post by P Wesberg » Wed Aug 07, 2019 9:13 am

Dear All,

I try to work with the OpenSim python wrapping. To run OpenSim-core-installation via python3 wrapping in an anaconda environment I installed OpenSim-Core following the procedure for MacOS with superbuild using Cmake and Xcode. The following problem occurs trying to import opensim:

Code: Select all

ImportError: dlopen(/Applications/anaconda3/envs/simenv/lib/python3.7/site-packages/opensim-4.0-py3.7.egg/opensim/_simbody.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.7/Python
The folder "/Library/Frameworks/Python.framework/Versions/3.7/Python" does not exist. I think it should points to the Anaconda Python instead?
But maybe this is a wrong interpretation of this error report :-)

Please help!
Thanks a lot, Philippe

complete error code:

Code: Select all

(simenv) ip184103:~ philippewesberg$ python
Python 3.7.3 (default, Mar 27 2019, 16:54:48) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import opensim
Traceback (most recent call last):
  File "/Applications/anaconda3/envs/simenv/lib/python3.7/site-packages/opensim-4.0-py3.7.egg/opensim/simbody.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/Applications/anaconda3/envs/simenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: dlopen(/Applications/anaconda3/envs/simenv/lib/python3.7/site-packages/opensim-4.0-py3.7.egg/opensim/_simbody.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.7/Python
  Referenced from: /Applications/anaconda3/envs/simenv/lib/python3.7/site-packages/opensim-4.0-py3.7.egg/opensim/_simbody.so
  Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/anaconda3/envs/simenv/lib/python3.7/site-packages/opensim-4.0-py3.7.egg/opensim/__init__.py", line 1, in <module>
    from .simbody import *
  File "/Applications/anaconda3/envs/simenv/lib/python3.7/site-packages/opensim-4.0-py3.7.egg/opensim/simbody.py", line 17, in <module>
    _simbody = swig_import_helper()
  File "/Applications/anaconda3/envs/simenv/lib/python3.7/site-packages/opensim-4.0-py3.7.egg/opensim/simbody.py", line 16, in swig_import_helper
    return importlib.import_module('_simbody')
  File "/Applications/anaconda3/envs/simenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_simbody'
>>> 

Tags:

User avatar
James Dunne
Posts: 1287
Joined: Thu Oct 04, 2007 11:51 pm

Re: OpenSim API Python Import Error: Library not loaded

Post by James Dunne » Wed Aug 07, 2019 10:50 am

Just to be clear, you are building OpenSim from source using the instructions found here?

Did you open the CMake GUI and check which Python path that your system is using to build against?

If you are using Mac, did you set your Python path correctly? Have you checked in Terminal by using 'which python'?

User avatar
P Wesberg
Posts: 2
Joined: Fri Jan 11, 2019 5:55 am

Re: OpenSim API Python Import Error: Library not loaded

Post by P Wesberg » Wed Aug 14, 2019 7:01 am

Dear James,

Yes, I've used the instructions you mentioned https://github.com/opensim-org/opensim-core as well as these for further settings https://simtk-confluence.stanford.edu:8 ... xvsPython3

In the CMake GUI I specified OPENSIM_python_version to 3. I don't See the option to specify the python path in the CMake GUI. But the environment shows the right path to anaconda python 3.7:

Code: Select all

Last login: Wed Aug 14 15:52:54 on ttys000
(base) ip184103:~ philippewesberg$ conda activate simenv
(simenv) ip184103:~ philippewesberg$ type -a python
python is /Applications/anaconda3/envs/simenv/bin/python
python is /usr/bin/python
(simenv) ip184103:~ philippewesberg$ python
Python 3.7.3 (default, Mar 27 2019, 16:54:48) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
PS: the first path which is printed using 'type -a python' is identically to what is printed by 'which python'

thanks for your help!

User avatar
Ayman Habib
Posts: 1559
Joined: Fri Apr 01, 2005 12:24 pm

Re: OpenSim API Python Import Error: Library not loaded

Post by Ayman Habib » Thu Aug 15, 2019 1:59 pm

Hello,

In CMake GUI, if you enable view of Advanced options (checkbox) then you should see "PYTHON_EXECUTABLE", make sure that it points to the python that you intend to use. In general we build/test against standard python from python.org and not custom installations (e.g. Anaconda) which may introduce other unknowns.

Please let us know what you find out.

Best regards,
-Ayman

POST REPLY