System Integrity Protection breaks DYLD_LIBRARY_PATH for python scripts
2
votes
1
answer
1772
views
I have some custom modules that are generated using SWIG that are installed in a a local path eg:
catkin_ws/devel/lib/python2.7/site-packages
When I try to run a python script that uses one of these modules, I get an import error:
"/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named _mag_manip
I've figured out that this is due to the shebang at the top of the python script:
#!/usr/bin/env python
Because /usr/bin/env is protected by System Integrity Protection (SIP), the DYLD_LIBRARY_PATH environment variable is not loaded and some modules cannot be found. A fix is to replace the shebang with the hardcoded path of python ie:
#!/usr/local/bin/python
Since my code runs on Linux and Mac OSX, replacing the normal python shebang with a hardcoded path on mac is not a really good solution. Does anybody know what the best solution is here?
Asked by user3293204
(31 rep)
Jun 9, 2017, 10:32 AM
Last activity: Dec 4, 2018, 11:02 PM
Last activity: Dec 4, 2018, 11:02 PM