https://pantsbuild.org/ logo
#general
Title
# general
b

bland-father-19717

05/11/2022, 9:43 AM
I got the following error when trying to import pyqt5. Is there a good solution?
Copy code
from PyQt5.QtWidgets import QApplication
ImportError: dlopen(/Users/xxx/.cache/pants/named_caches/pex_root/installed_wheels/33ced1c876f6a26e7899615a5a4efef2167c263488837c7beed023a64cebd051/PyQt5-5.15.6-cp36-abi3-macosx_10_13_x86_64.whl/PyQt5/QtWidgets.abi3.so, 2): Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets
  Referenced from: /Users/xxx/.cache/pants/named_caches/pex_root/installed_wheels/33ced1c876f6a26e7899615a5a4efef2167c263488837c7beed023a64cebd051/PyQt5-5.15.6-cp36-abi3-macosx_10_13_x86_64.whl/PyQt5/QtWidgets.abi3.so
  Reason: image not found
e

enough-analyst-54434

05/11/2022, 2:39 PM
That just means the
PyQt5-5.15.6
wheel is not self contained with a fully static Qt. It relies on Qt being installed on the local machine. So you'll need to install Qt on any machine that wants to run a PEX with that
PyQt5-5.15.6
wheel as a dependency. To be clear, this is not a PEX specific problem. Just examining the wheel contents directly can let you know if the wheel will work on your machine. For example, on my machine it will not:
Copy code
$ curl -sSL <https://files.pythonhosted.org/packages/36/66/19983d471c702e551a19a7225a92a7c1efadd961f6c650110ed906dd0ed7/PyQt5-5.15.6-cp36-abi3-manylinux1_x86_64.whl> -O
$ mkdir PyQt5-5.15.6
$ unzip -d PyQt5-5.15.6 PyQt5-5.15.6-cp36-abi3-manylinux1_x86_64.whl
$ ldd PyQt5-5.15.6/PyQt5/QtWidgets.abi3.so 
ldd: warning: you do not have execution permission for `PyQt5-5.15.6/PyQt5/QtWidgets.abi3.so'
	linux-vdso.so.1 (0x00007fff1a0ba000)
	libQt5Widgets.so.5 => not found
	libQt5Gui.so.5 => not found
	libQt5Core.so.5 => not found
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f8d67bb1000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f8d679a7000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007f8d678bd000)
	/usr/lib64/ld-linux-x86-64.so.2 (0x00007f8d68379000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f8d678a2000)
Note there are three expected shared libraries that do not link on my machine since I don't have Qt installed at all (I run Gnome, not KDE).
b

bland-father-19717

05/12/2022, 5:47 AM
Thanks for the quick reply. I understand that it is difficult to solve the problem. I could not execute the command immediately because our environment is macos, but why was the execution successful when I did
poetry run python main.py
? pyproject.toml
Copy code
[tool.poetry.dependencies]
python = "^3.8"
PyQt5 = "^5.15.6"
main.py
Copy code
from PyQt5.QtWidgets import QApplication
e

enough-analyst-54434

05/13/2022, 2:01 PM
I really have no clue @bland-father-19717. You're going to have to dig into the lines you snipped:
Copy code
dlopen(/Users/xxx/.cache/pants/named_caches/pex_root/installed_wheels/33ced1c876f6a26e7899615a5a4efef2167c263488837c7beed023a64cebd051/PyQt5-5.15.6-cp36-abi3-macosx_10_13_x86_64.whl/PyQt5/QtWidgets.abi3.so, 2): Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets
  Referenced from: /Users/xxx/.cache/pants/named_caches/pex_root/installed_wheels/33ced1c876f6a26e7899615a5a4efef2167c263488837c7beed023a64cebd051/PyQt5-5.15.6-cp36-abi3-macosx_10_13_x86_64.whl/PyQt5/QtWidgets.abi3.so
  Reason: image not found
It looks like that requires understanding how RPATH works on Mac for a start.
b

bland-father-19717

05/14/2022, 9:25 AM
@enough-analyst-54434 Thanks for helping us with our investigation! I’ll look into it a bit.
4 Views