TagStudioDev / TagStudio

A User-Focused Photo & File Management System

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Facing an issue when trying to open an image file in a system viewer

ykonyshev opened this issue · comments

I am encountering an error when trying to open an image file by clicking on the image preview on the right-hand side of the UI.

image_2024-06-10_16-51-47
I suppose this is not strictly relevant as trying to open the image using the "Open file" context menu option also causes the same issue

Further details

The output of uname -a: Linux yevhenii-80nv 6.6.31-1-lts #1 SMP PREEMPT_DYNAMIC Fri, 17 May 2024 11:49:30 +0000 x86_64 GNU/Linux

I am running TagStudio with the following command: python ./tagstudio/tag_studio.py --ui qt (I have the virtual environment setup, the suggested dependencies specified in requirements.txt and requirements-dev.txt are installed, and the environment is activated)

Here are some relevant logs:

Opening file: /tmp/temp/random_images/MyTaken/_DSC8578.jpg
QObject::moveToThread: Current thread (0x60db0c9ebcb0) is not the object's thread (0x60db0c9f9280).
Cannot move to target thread (0x60db0c9ebcb0)

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins" 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: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx.

/usr/bin/xdg-open: line 909: 760306 Aborted                 (core dumped) env "$command" "$@"

The solution that worked for me

Running pip uninstall opencv-python and pip install opencv-python-headless seems to resolve the issue.

As far as I understand the issue in the first place is caused by opencv-python providing the libqxcb.so shared object, due to it supporting GUI preview built with Qt, that somehow conflicts with my image viewer (it's qimgv, which is also build using Qt) and causes it to produce the aforementioned error about not being able to load the Qt plugin. After the opencv-python package is replaced with opencv-python-headless qimgv most likely uses the system libqxcb.so located at /usr/lib/qt/plugins/platforms/libqxcb.so and I am able to open the image file from the TagStudio GUI without any issues.

My suggestion would be to replace the opencv-python package with opencv-python-headless, as no GUI preview funtionality provided by opencv-python seems to be used and I suppose won't be used in the future.

I am not certain whether this issue will persist outside the development enviroment, due to this being presumably caused by the inner workings of the virtual environments, but I still consider this an issue worth mentioning.

Addressing other solution mentioned on the internet that wasn't the case for me

The libqxcb.so shared object's dependencies

I have tried looking up the issue and many people suggest that the issue was related to the libqxcb.so shared object and its possibly missing dependencies. Here the object is located at /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/libqxcb.so.

I tried running ldd /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/libqxcb.so as suggested. Here is the output:


        linux-vdso.so.1 (0x00007ffccf122000)
        libQt5XcbQpa-5b2d853e.so.5.15.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libQt5XcbQpa-5b2d853e.so.5.15.0 (0x00007384f70c6000)
        libpng16-7379b3c3.so.16.40.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libpng16-7379b3c3.so.16.40.0 (0x00007384f708f000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007384f704a000)
        libQt5Gui-a7aedf18.so.5.15.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libQt5Gui-a7aedf18.so.5.15.0 (0x00007384f6600000)
        libQt5Core-39545cc7.so.5.15.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libQt5Core-39545cc7.so.5.15.0 (0x00007384f5e00000)
        libGL.so.1 => /usr/lib/libGL.so.1 (0x00007384f6fc2000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007384f6fbd000)
        libX11-xcb-69166bdf.so.1.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libX11-xcb-69166bdf.so.1.0.0 (0x00007384f5a00000)
        libxcb-icccm-413c9f41.so.4.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-icccm-413c9f41.so.4.0.0 (0x00007384f5600000)
        libxcb-image-e82a276d.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-image-e82a276d.so.0.0.0 (0x00007384f5200000)
        libxcb-shm-7a199f70.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-shm-7a199f70.so.0.0.0 (0x00007384f4e00000)
        libxcb-keysyms-21015570.so.1.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-keysyms-21015570.so.1.0.0 (0x00007384f4a00000)
        libxcb-randr-a96a5a87.so.0.1.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-randr-a96a5a87.so.0.1.0 (0x00007384f4600000)
        libxcb-render-util-43ce00f5.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-render-util-43ce00f5.so.0.0.0 (0x00007384f4200000)
        libxcb-render-637b984a.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-render-637b984a.so.0.0.0 (0x00007384f3e00000)
        libxcb-shape-25c2b258.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-shape-25c2b258.so.0.0.0 (0x00007384f3a00000)
        libxcb-sync-89374f40.so.1.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-sync-89374f40.so.1.0.0 (0x00007384f3600000)
        libxcb-xfixes-9be3ba6f.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-xfixes-9be3ba6f.so.0.0.0 (0x00007384f3200000)
        libxcb-xinerama-ae147f87.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-xinerama-ae147f87.so.0.0.0 (0x00007384f2e00000)
        libxcb-xkb-9ba31ab3.so.1.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-xkb-9ba31ab3.so.1.0.0 (0x00007384f2a00000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007384f6f8c000)
        libXext.so.6 => /usr/lib/libXext.so.6 (0x00007384f6f77000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0x00007384f5cc2000)
        libSM.so.6 => /usr/lib/libSM.so.6 (0x00007384f6f6c000)
        libICE.so.6 => /usr/lib/libICE.so.6 (0x00007384f6f4e000)
        libxkbcommon-x11-c65ed502.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxkbcommon-x11-c65ed502.so.0.0.0 (0x00007384f2600000)
        libxkbcommon-71ae2972.so.0.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxkbcommon-71ae2972.so.0.0.0 (0x00007384f2200000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007384f6f47000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007384f1e00000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007384f6515000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007384f6f18000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007384f5814000)
        libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007384f6f13000)
        libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007384f54b2000)
        /usr/lib64/ld-linux-x86-64.so.2 (0x00007384f728a000)
        libGLdispatch.so.0 => /usr/lib/libGLdispatch.so.0 (0x00007384f5c0a000)
        libGLX.so.0 => /usr/lib/libGLX.so.0 (0x00007384f6edf000)
        libxcb-util-4d666913.so.1.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libxcb-util-4d666913.so.1.0.0 (0x00007384f1a00000)
        libXau-00ec42fe.so.6.0.0 => /mnt/data/code/Python/Other/TagStudio/.venv/lib/python3.12/site-packages/cv2/qt/plugins/platforms/../../../../opencv_python.libs/libXau-00ec42fe.so.6.0.0 (0x00007384f1600000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0x00007384f6eda000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007384f6ed0000)
        libuuid.so.1 => /usr/lib/libuuid.so.1 (0x00007384f6ec6000)
        libpcre2-8.so.0 => /usr/lib/libpcre2-8.so.0 (0x00007384f5414000)

As you can see, there are no missing dependencies, so this doesn't seem to be causing the issue.

This seems related to (but not the same as) #210, where the problem is the path where libs are being loaded from, which we need to somehow filter to use from the system.
Using the headless dependency is a good idea to explore, that was something we were unaware of, but it only delays this issue: it would come back in the event a dependency is added that uses the same lib again.