Search code examples
pythongitlab-cipyside6

Why does PySide6 on GitLab CI result in ImportError?


I'm trying to get PySide6 installed on a CI environment (company internal GitLab instance) using the docker hub python 3.8 image, but I'm having issues when importing from PySide6. Below is the relevant portion of the .gitlab-ci.yml file, where $IMAGE references the above mentioned docker image.

test-pyside6
  stage: testing
  image: $IMAGE
  script:
    - python -m venv .venv
    - . .venv/bin/activate
    - which python
    - python --version
    - python -m pip install --upgrade pip setuptools wheel
    - python -m pip install PySide6
    - python -c 'import PySide6; print(PySide6.__version__)'
    - ldd <snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Core.so.6
    - python -c 'import PySide6.QtCore'

The outputs are as expected, except the last line which errors on importing QtCore. As far as I can tell, the result of ldd is good too (no "not found" messsages). Note that import PySide6 works just fine.

Executing "step_script" stage of the job script
$ python -m venv .venv
$ . .venv/bin/activate
$ which python
<snip>/.venv/bin/python
$ python --version
Python 3.8.10
$ python -m pip install --upgrade pip setuptools wheel
<snip>
Successfully installed pip-21.2.4 setuptools-58.0.4 wheel-0.37.0
$ python -m pip install PySide6
<snip>
Successfully installed PySide6-6.1.3 shiboken6-6.1.3
$ python -c 'import PySide6; print(PySide6.__version__)'
6.1.3
$ ldd <snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Core.so.6
    linux-vdso.so.1 (0x00007ffd55f54000)
    libicui18n.so.56 => <snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libicui18n.so.56 (0x00007f82c43ad000)
    libicuuc.so.56 => <snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libicuuc.so.56 (0x00007f82c3ff5000)
    libicudata.so.56 => <snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libicudata.so.56 (0x00007f82c2612000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f82c2604000)
    libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f82c24e5000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f82c24c2000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f82c22a4000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f82c229f000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f82c2295000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f82c2111000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f82c1f8e000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f82c1f74000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f82c1db1000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f82c4e46000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f82c1d3d000)
$ python -c 'import PySide6.QtCore'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: libQt6Core.so.6: cannot open shared object file: No such file or directory

I also tried a number of other things, all with the same error message:

  • Changing the last line to python -c 'import PySide6; import PySide6.QtCore'
  • Not using a virtual environment
  • Using a script/file instead of a string as the python input (python test.py)
  • Setting PYTHONPATH and/or LD_LIBRARY_PATH
  • Adding the appropriate library location to /etc/ld.so.conf.d/pyside.conf following by ldconfig -v (verbose output of this shows that libQt6Core.so.6 was found and added: libQt6Core.so.6 -> libQt6Core.so.6)

Next, I installed strace and changed the last line to:

    - strace -o output.txt python -c 'from PySide6 import QtCore' || true
    - cat "output.txt"

A snippet of the output is below

$ strace -s 300 -o output.txt python -c 'from PySide6 import QtCore' || true
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: libQt6Core.so.6: cannot open shared object file: No such file or directory
$ cat "output.txt"
<snip>
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/libpyside6.abi3.so.6.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\321\0\0\0\0\0\0"..., 832) = 832
lseek(3, 335872, SEEK_SET)              = 335872
read(3, "\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 448) = 448
fstat(3, {st_mode=S_IFREG|0755, st_size=354424, ...}) = 0
lseek(3, 335872, SEEK_SET)              = 335872
read(3, "\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 448) = 448
mmap(NULL, 2377848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffad0b64000
mprotect(0x7ffad0ba1000, 2109440, PROT_NONE) = 0
mmap(0x7ffad0da0000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3c000) = 0x7ffad0da0000
mmap(0x7ffad0da3000, 1000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffad0da3000
mmap(0x7ffad0da4000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x52000) = 0x7ffad0da4000
close(3)                                = 0
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/tls/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/tls/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/tls/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/tls/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/tls/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/tls/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/tls/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/tls", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320@\f\0\0\0\0\0"..., 832) = 832
close(3)                                = 0
stat("<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=35925, ...}) = 0
mmap(NULL, 35925, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffad0b5b000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/tls/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/tls/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/tls/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/tls/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=50, ...}) = 0
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/tls/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/tls/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/tls/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
openat(AT_FDCWD, "/lib/tls/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/tls/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/tls/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/tls/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls", 0x7fff8bf4e570)        = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/haswell", 0x7fff8bf4e570)    = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7fff8bf4e570)     = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib", {st_mode=S_IFDIR|0755, st_size=41, ...}) = 0
openat(AT_FDCWD, "/usr/lib/tls/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/tls/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/tls/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/tls/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls", 0x7fff8bf4e570)    = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/haswell/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/haswell/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/haswell/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/haswell", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7fff8bf4e570) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=30, ...}) = 0
munmap(0x7ffad0b5b000, 35925)           = 0
munmap(0x7ffad0da9000, 7836840)         = 0
munmap(0x7ffad0b64000, 2377848)         = 0
openat(AT_FDCWD, "<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/python38.zip/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/python3.8/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/local/lib/python3.8/lib-dynload/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, "Traceback (most recent call last"..., 162) = 162
rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7ffad26e4730}, {sa_handler=0x7ffad2835052, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7ffad26e4730}, 8) = 0
munmap(0x7ffad1523000, 262144)          = 0
sigaltstack(NULL, {ss_sp=0x558a1d689910, ss_flags=0, ss_size=16384}) = 0
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}, NULL) = 0
exit_group(1)                           = ?
+++ exited with 1 +++

I believe that it shows that the library was found, from the extract below (which is the correct location where the file exists).

openat(AT_FDCWD, "<snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Core.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320@\f\0\0\0\0\0"..., 832) = 832
close(3)                                = 0

Why does it then continue trying to find libQt6Core.so.6 in other locations after it found it? And why does it report not found, when it is found? Is there something else I can try to make this work? For what it's worth, changing PySide6 to PySide2 works just fine. But I'm trying to using PySide6 here, obviously. Lastly, installing the same version of PySide6 on my personal Ubuntu machine, also in a virtual environment, works just fine.


Solution

  • I found the solution, although I have to admit that I have absolutely no clue what this actually does:

    https://askubuntu.com/a/1163268

    So after installing PySide6 in the virtual environment, I added the strip command on the libQt6Core library as shown below. Then the import works just fine.

    test-pyside6
      stage: testing
      image: $IMAGE
      script:
        - python -m venv .venv
        - . .venv/bin/activate
        - which python
        - python --version
        - python -m pip install --upgrade pip setuptools wheel
        - python -m pip install PySide6
        - strip --remove-section=.note.ABI-tag <snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Core.so.6
        - python -c 'import PySide6; print(PySide6.__version__)'
        - ldd <snip>/.venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Core.so.6
        - python -c 'import PySide6.QtCore'