Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Unable to Shipping With Python
MemphisWang last edited by MemphisWang
Hi all, I'm writing a Qt program with Python embedded. I use the old embed way (python.h, not CFFI).
It works fine on my creator. But when i try to deploy my program. macdeployqt couldn't help me deploy python.Framework to Frameworks. And the Qt program try to use user's own python environment which is not what i want.
And Google tells me very little thing about how to deploy python framework when you are embedding it.
Does anyone try this before? Or Where can i get the right information about how to ship Qt program with python embedded. many thanks
when macdeployqt, it shows this:
ERROR: no file at "/usr/local/opt/python/lib/Python.framework/Versions/2.7/Python"
but my python is not here. where should i specific this path for macdeployqt to find Python?
i can only copy python.framework by my self now. still want it processed by macdeployqt automate
One thing you can try is to use the
macdeployqtto give add additional search path that the tool will use to search for libraries/frameworks.
Hope it helps
@SGaist didn't work.
BTW, when otool -L my binary
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1348.28.0) @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.8.0, current version 5.8.0) @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.8.0, current version 5.8.0) @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.8.0, current version 5.8.0) ...
that happened before i use macdeployqt.
So the path has been set when the binary is created. and macdeployqt copy frameworks according to this. And my Python.Framework is in the wrong place since then.
@SGaist For now I have to workaround like this:
- build my code.
install_name_tool -change /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python @executable_path/../Frameworks/Python.framework/Versions/2.7/Python
- copy Python.Framework to Frameworks manually
It works, but I'm not very confident with it.
It should be the other way around, copy the framework first and then update the paths inside it. That's basically what
Yes, It sounds reasonable that macdeployqt use these shared library information to deploy frameworks.
so I take your advice, use install_name_tool to specify my Framework path, try to let macdeployqt to finish the deploy work. And the result is frustrating again:
- otool shows it's using:
- macdeployqt try to find in:
T^T ... So werid.
after that, i create a link name "lib" and link to "mac", hope it can help macdeployqt to find the right Framework. and it didn't help, the problem stays all the same
In that kind of corner cases, the fastest is to write a small script that run macdeployqt on your application bundle, then copy the problematic frameworks and update their paths.
@SGaist Yes that's how i fix it now. maybe macdeployqt is designed to deploy only qt framework. we should do the rest.
No it's not, however it's easy to be using additional frameworks that may have some quirks once deployed which usually not your fault since you follow their installation instructions.
@SGaist With this workaround, I should mark this as solved