I'm trying to import PySide / Qt into Python like so and get the follow error:
from PySide import QtCore
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PySide/QtCore.so, 2): Library not loaded: libpyside-python2.7.1.2.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/PySide/QtCore.so
Reason: image not found
I'm running/installed via:
The file libpyside-python2.7.1.2.dylib is located in the same path as the QtCore.so file listed in the error message.
All my searches for this particular problem have yielded people trying to package these libraries as part of an app, which I am not doing. I am just trying to run it on my system and yet have this problem. For troubleshooting an app, people suggested oTool; not sure if it is helpful here, but this is the output when I run oTool:
otool -L QtCore.so
QtCore.so:
libpyside-python2.7.1.2.dylib (compatibility version 1.2.0, current version 1.2.2)
libshiboken-python2.7.1.2.dylib (compatibility version 1.2.0, current version 1.2.2)
/usr/local/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.6)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
Any ideas? Thanks in advance :)
The key difference in the two versions — in fact the entire reason PySide2 exists — is licensing. PyQt5 is available under a GPL or commercial license, and PySide2 under a LGPL license.
PySide is a Python binding of the cross-platform GUI toolkit Qt developed by The Qt Company, as part of the Qt for Python project. It is one of the alternatives to the standard library package Tkinter. Like Qt, PySide is free software.
Pyodide is a port of CPython to WebAssembly/Emscripten. Pyodide makes it possible to install and run Python packages in the browser with micropip. Any pure Python package with a wheel available on PyPI is supported. Many packages with C extensions have also been ported for use with Pyodide.
PySide is a binding to Qt4, whereas PySide2 is a binding to Qt5. or if you want to be prepared for all cases… And there are versions of PySide2 for Python 2.7, too.
Well, the installer is somewhat broken, because the output from oTool should report a full path to the library (the path should be changed by the Pyside installer using install_name_tool).
Instead of going mad understanding what part of the installer is broken, I suggest you define:
DYLD_LIBRARY_PATH=/your/path/to/pyside/libraries
export DYLD_LIBRARY_PATH
This will force the executable loader to scan for libraries into the path you supply too, even it's not configured by the linker.
if you watch this , you're question will be fixed: https://github.com/pyside/packaging/blob/master/setuptools/templates/pyside_postinstall.py
pyside_postinstall.py -install
I had a similar issue, and I resolved it by manually using otool -L
(as seen in the question) and install_name_tool
to update the paths.
install_name_tool -change @rpath/libshiboken.cpython-34m.1.2.dylib /usr/local/lib/python3.4/site-packages/PySide/libshiboken.cpython-34m.1.2.dylib /usr/local/lib/python3.4/site-packages/PySide/QtCore.so
install_name_tool -change @rpath/libpyside.cpython-34m.1.2.dylib /usr/local/lib/python3.4/site-packages/PySide/libpyside.cpython-34m.1.2.dylib /usr/local/lib/python3.4/site-packages/PySide/QtCore.so
I had to do this for several files in the PySide directory before the script would run.
This blog post is a nice reference: http://thecourtsofchaos.com/2013/09/16/how-to-copy-and-relink-binaries-on-osx/
i found a solution here
export DYLD_LIBRARY_PATH=/usr/local/lib/python[version]/site-packages/PySide
for python 3.5 this would be
export DYLD_LIBRARY_PATH=/usr/local/lib/python3.5/site-packages/PySide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With