- Sat Aug 08, 2015 9:30 pm
#387637
Found a fix for this little PyThreadState_Get problem on OSX using install_name_tool (which I think comes bundled with xcode)
1) Use otool to inspect existing links:
$ otool -L /Users/dave/Desktop/pymaxwell/python2.7/_pymaxwell.so
gives:
/Users/dave/Desktop/pymaxwell/python2.7/_pymaxwell.so:
/usr/local/lib/_pymaxwell.so (compatibility version 1.0.0, current version 1.0.0)
/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0) <---- this is the python path we want to edit
/usr/lib/libz.1.dylib (compatibili....
2) Change the linked python path using install_name_tool:
$ install_name_tool -change /system/python/path /your/python/path _pymaxwell.so
For example if this is the path to homebrew python: /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/Python
$ install_name_tool -change /Library/Frameworks/Python.framework/Versions/2.7/Python /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/Python /Users/dave/Desktop/pymaxwell/python2.7/_pymaxwell.so
3) Use otool -L again to verify the change
4) Test import pymaxwell in the homebrew python console.
import sys
sys.path.insert(0,'/Users/dave/Desktop/pymaxwell/python2.7')
import pymaxwell
If it's worked you won't get a PyThreadState_Get error. Phew.
1) Use otool to inspect existing links:
$ otool -L /Users/dave/Desktop/pymaxwell/python2.7/_pymaxwell.so
gives:
/Users/dave/Desktop/pymaxwell/python2.7/_pymaxwell.so:
/usr/local/lib/_pymaxwell.so (compatibility version 1.0.0, current version 1.0.0)
/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0) <---- this is the python path we want to edit
/usr/lib/libz.1.dylib (compatibili....
2) Change the linked python path using install_name_tool:
$ install_name_tool -change /system/python/path /your/python/path _pymaxwell.so
For example if this is the path to homebrew python: /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/Python
$ install_name_tool -change /Library/Frameworks/Python.framework/Versions/2.7/Python /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/Python /Users/dave/Desktop/pymaxwell/python2.7/_pymaxwell.so
3) Use otool -L again to verify the change
4) Test import pymaxwell in the homebrew python console.
import sys
sys.path.insert(0,'/Users/dave/Desktop/pymaxwell/python2.7')
import pymaxwell
If it's worked you won't get a PyThreadState_Get error. Phew.