pyinat / naturtag

Tag your nature photos with iNat taxonomy and observation metadata
https://naturtag.readthedocs.io
MIT License
37 stars 4 forks source link

Installation issues #313

Closed max-mapper closed 1 year ago

max-mapper commented 1 year ago

I am on Arch Linux, python 3.10.9 and am having issues installing the package to test out the GUI

I first tried the binary distribution (naturtag-linux.tar.gz) off the latest release but running ./naturtag results in Segmentation fault (core dumped). Then I tried pip install naturtag. I ran naturtag-gui and it complained about a missing tablib package, which I installed with pip install tablib. Running it now I get this stacktrace:

Traceback (most recent call last):
  File "/home/max/.local/bin/naturtag-ui", line 5, in <module>
    from naturtag.app.app import main
  File "/home/max/src/naturtag/naturtag/__init__.py", line 2, in <module>
    from naturtag.metadata import MetaMetadata, refresh_tags, tag_images
  File "/home/max/src/naturtag/naturtag/metadata/__init__.py", line 5, in <module>
    from naturtag.metadata.image_metadata import ImageMetadata
  File "/home/max/src/naturtag/naturtag/metadata/image_metadata.py", line 9, in <module>
    from naturtag.utils.image_glob import get_sidecar_path
  File "/home/max/src/naturtag/naturtag/utils/__init__.py", line 3, in <module>
    from naturtag.utils.thumbnails import generate_thumbnail
  File "/home/max/src/naturtag/naturtag/utils/thumbnails.py", line 8, in <module>
    from PySide6.QtGui import QPixmap
ModuleNotFoundError: No module named 'PySide6.QtGui'

I tried uninstalling and reinstalling PySide6 but I still get the same error... any ideas? I also tried cloning the repo and running pip install . but I get the same result as pip install naturtag.

JWCook commented 1 year ago

Thanks for the info! I don't know off the top of my head what would cause that traceback, but I'll look into it and get back to you.

The segfault you initially got will be harder to debug... And the missing tablib dependency should be fixed in main, but I haven't made a patch release for that yet.

JWCook commented 1 year ago

I just rebuilt packages from the main branch: https://github.com/pyinat/naturtag/actions/runs/4663516616

Try installing the Linux PyInstaller package there, and let me know what happens.

Since that includes several work-in-progress changes, it's possible some other errors could come up (like #307), but I'd mainly like to see if you still get that segmentation fault.

max-mapper commented 1 year ago

Thanks! I downloaded naturtag-linux.tar.gz and got a new error:

$ ./naturtag 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: wayland, minimal, wayland-egl, linuxfb, xcb, vkkhrdisplay, minimalegl, eglfs, offscreen, vnc.

Aborted (core dumped)

I ran it with QT_DEBUG_PLUGINS=1 ./naturtag and it included this:

qt.core.library: "/home/max/Desktop/naturtag-linux2/PySide6/Qt/plugins/platforms/libqxcb.so" cannot load: Cannot load library /home/max/Desktop/naturtag-linux2/PySide6/Qt/plugins/platforms/libqxcb.so: (/usr/lib/libQt6XcbQpa.so.6: undefined symbol: _ZN22QWindowSystemInterface22handleExtendedKeyEventEP7QWindowmN6QEvent4TypeEi6QFlagsIN2Qt16KeyboardModifierEEjjjRK7QStringbtb, version Qt_6_PRIVATE_API)
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/max/Desktop/naturtag-linux2/PySide6/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/max/Desktop/naturtag-linux2/PySide6/Qt/plugins/platforms/libqxcb.so: (/usr/lib/libQt6XcbQpa.so.6: undefined symbol: _ZN22QWindowSystemInterface22handleExtendedKeyEventEP7QWindowmN6QEvent4TypeEi6QFlagsIN2Qt16KeyboardModifierEEjjjRK7QStringbtb, version Qt_6_PRIVATE_API)"

Can you compile it without any shared libraries?

JWCook commented 1 year ago

All of the QT binaries included in that package are pre-compiled and distributed with PySide6. I'd rather avoid compiling that from source if possible, so let's try a few other things first.

Some of the other libraries come from the build environment and are collected by PyInstaller. It's possible it needs to install some additional XCB packages before building (here) and/or explicitly include another library in the PyInstaller spec (here) if it's not collecting it automatically. Possibly libxcb-keysyms? Just a guess based on that variable name that contains ExtendedKeyEvent...KeyboardModifier.

Could you run:

ldd /home/max/Desktop/naturtag-linux2/PySide6/Qt/plugins/platforms/libqxcb.so

And tell me if any of those libraries are listed as "not found"? Also, are you running under X11, or Wayland?

Another thing to try that may help narrow it down a bit:

Meanwhile, I'll try to reproduce this locally. Sorry for the hassle, and thanks for helping to debug this!

max-mapper commented 1 year ago

I'm on X11. I get one 'not found' message:

$ ldd /home/max/Desktop/naturtag-linux2/PySide6/Qt/plugins/platforms/libqxcb.so /home/max/Desktop/naturtag-linux2/PySide6/Qt/plugins/platforms/libqxcb.so: /usr/lib/libQt6Core.so.6: version `Qt_6.5' not found (required by /home/max/Desktop/naturtag-linux2/PySide6/Qt/plugins/platforms/libqxcb.so)

Good news though! These commands got it working for me:

cd naturtag
python -m venv venv
source venv/bin/activate
pip install .
naturtag-ui
JWCook commented 1 year ago

Oh, great! When you previously got that ModuleNotFoundError: No module named 'PySide6.QtGui', was that running outside of a virtualenv? Usually the problem there is a mismatch between the python interpreter that runs it vs. the interpreter associated with the default pip that actually installed the packages. In that case, the fix is either:

But it's generally best to stick with virtualenvs instead of the user site-packages.

/usr/lib/libQt6Core.so.6: version 'Qt_6.5' not found

Interesting, it looks like it's trying to use your system-level libQt6Core.so (i.e., from a package installed with pacman that depends on Qt) instead of the one included in the Naturtag package, and the system-level version must be something older than 6.5.

Any ideas why that would happen? Off the top of my head, I'm not sure if that would just be an issue with the order of paths in $PATH, or a problem with how the Naturtag package is being built. My experience with C/C++ and dynamic libraries is fairly rusty.

JWCook commented 1 year ago

I'm going to call this done, but let me know if you have any more issues or questions!