This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

pc-ble-driver-py on Mac: ImportError: Image not found

Hi,

Getting this error using the latest version of pc-ble-driver-py on Mac with the latest version of Catalina for the example application heart_rate_collector from the examples folder:

Traceback (most recent call last):
  File "./heart_rate_collector.py", line 208, in <module>
    init(sys.argv[1])
  File "./heart_rate_collector.py", line 56, in init
    from pc_ble_driver_py.ble_driver import (
  File "/Users/espen/.virtualenvs/hypersension-isenseu-console/lib/python3.8/site-packages/pc_ble_driver_py/ble_driver.py", line 77, in <module>
    import pc_ble_driver_py.lib.nrf_ble_driver_sd_api_v5 as driver
  File "/Users/espen/.virtualenvs/hypersension-isenseu-console/lib/python3.8/site-packages/pc_ble_driver_py/lib/nrf_ble_driver_sd_api_v5.py", line 13, in <module>
    from . import _nrf_ble_driver_sd_api_v5
ImportError: dlopen(/Users/espen/.virtualenvs/hypersension-isenseu-console/lib/python3.8/site-packages/pc_ble_driver_py/lib/_nrf_ble_driver_sd_api_v5.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.8/Python
  Referenced from: /Users/espen/.virtualenvs/hypersension-isenseu-console/lib/python3.8/site-packages/pc_ble_driver_py/lib/_nrf_ble_driver_sd_api_v5.so
  Reason: image not found

I've tried every combination possible of python installations, from using brew, standard installation from python.org, Anaconda to using pyenv. I've also tested using an isolated environment using pyenv and virtualenvwrapper, which is supposed to create a completely isolated python environment including plugins/packages. 

As you can see from the error message, _nrf_ble_driver_sd_api_v5.so is trying to access a library in /Library/Frameworks/Python.framework/Versions/3.8/Python. This folder does not exist, and looking at my environment settings, to paths are pointing to this directory either. 

Any help on this is much appreciated!

Parents
  • You guys hardcoded your library to look for python in a location where it's no longer installed, as of Monterey.

    ImportError: dlopen(.../lib/python3.9/site-packages/pc_ble_driver_py/lib/_nrf_ble_driver_sd_api_v5.so, 0x0002): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.9/Python
      Referenced from: .../lib/python3.9/site-packages/pc_ble_driver_py/lib/_nrf_ble_driver_sd_api_v5.so
      Reason: tried: '/Library/Frameworks/Python.framework/Versions/3.9/Python' (no such file), '/System/Library/Frameworks/Python.framework/Versions/3.9/Python' (no such file)
    

    I can work around the issue by creating a symlink

    ln -s /usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/ /Library/Frameworks/Python.framework/Versions/3.9
    

    but I shouldn't have to. This should be fixed to work with python installs in the new location.

Reply
  • You guys hardcoded your library to look for python in a location where it's no longer installed, as of Monterey.

    ImportError: dlopen(.../lib/python3.9/site-packages/pc_ble_driver_py/lib/_nrf_ble_driver_sd_api_v5.so, 0x0002): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.9/Python
      Referenced from: .../lib/python3.9/site-packages/pc_ble_driver_py/lib/_nrf_ble_driver_sd_api_v5.so
      Reason: tried: '/Library/Frameworks/Python.framework/Versions/3.9/Python' (no such file), '/System/Library/Frameworks/Python.framework/Versions/3.9/Python' (no such file)
    

    I can work around the issue by creating a symlink

    ln -s /usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/ /Library/Frameworks/Python.framework/Versions/3.9
    

    but I shouldn't have to. This should be fixed to work with python installs in the new location.

Children
No Data
Related