Reputation: 187
I have a python project that I am trying to test with Tox in GitHub Actions. Unfortunately the package PySide6 and its Qt modules causes Tox to fail when I have any python file that has any kind of import such as the following:
from PySide6.QtWidgets import QApplication
The issue seems to be the fact that PySide6's Qt modules cannot be located/opened/or something else during the github action run. If I change the import to simply import PySide6
(or only use any other package like pandas for example) and run my tox github action again, everything passes successfully.
I looked at PySide6's __init__.py
and noticed that it seems to load its Qt modules in a non-traditional way and was wondering if that had something to do with it.
Regardless, here is the error message I get from tox in github actions when I have something like from PySide6.QtWidgets import QApplication
in my code...
Installing the current project: hpm_test (0.0.1)
py311: commands[1]> pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml
============================= test session starts ==============================
platform linux -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0
cachedir: .tox/py311/.pytest_cache
rootdir: /home/runner/work/hpm-test/hpm-test
plugins: cov-4.0.0
collected 0 items / 2 errors
==================================== ERRORS ====================================
______________________ ERROR collecting tests/test_foo.py ______________________
tests/test_foo.py:3: in <module>
from hpm_test.foo import foo, pan_check
hpm_test/foo.py:2: in <module>
from PySide6.QtWidgets import QApplication
E ImportError: libEGL.so.1: cannot open shared object file: No such file or directory
______________________ ERROR collecting tests/test_foo.py ______________________
ImportError while importing test module '/home/runner/work/hpm-test/hpm-test/tests/test_foo.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/importlib/__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_foo.py:3: in <module>
from hpm_test.foo import foo, pan_check
hpm_test/foo.py:2: in <module>
from PySide6.QtWidgets import QApplication
E ImportError: libEGL.so.1: cannot open shared object file: No such file or directory
---------- coverage: platform linux, python 3.11.2-final-0 -----------
Coverage XML written to file coverage.xml
=========================== short test summary info ============================
ERROR tests/test_foo.py - ImportError: libEGL.so.1: cannot open shared object...
ERROR tests/test_foo.py
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
============================== 2 errors in 0.77s ===============================
py311: exit 2 (1.30 seconds) /home/runner/work/hpm-test/hpm-test> pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml pid=1890
py311: FAIL code 2 (3.93=setup[0.87]+cmd[1.76,1.30] seconds)
evaluation failed :( (4.01 seconds)
Error: Process completed with exit code 2.
I can see that PySide6 and it's Qt modules do get installed by pip successfully before this test is run so I can't figure out why I'm getting the error. I even forcefully install the modules before the test to make sure they are in the environment:
- name: Manually install PySide6 modules
run: |
python -m pip uninstall pyside6 shiboken6 PySide6-Essentials PySide6-Addons
python -m pip cache purge
python -m pip install pyside6 shiboken6 PySide6-Essentials PySide6-Addons
I was initially led to this solution but I don't know if it applies to my situation and I'm not using docker and don't know how to convert this to a solution for me anyways.
(And by the way of course, running the tox
command locally produces no errors in any situation.)
How do I resolve my error with the PySide6 package causing this issue with Tox in GitHub Actions?
Upvotes: 3
Views: 460
Reputation: 105
Not entirely sure if this relates, but I had a similar issue with "libEGL.so.1 not found" when running unittests in a Github Action for a repo that used PySide6. My issue came from PySide6.QtUiTools import loadUiType
, and it seems this depended on the libEGL.so.1.
I added an additional step in my Workflow File:
- name: Install dependencies
run: |
sudo apt update && sudo apt install -y libegl1-mesa-dev
And that seemed to solve the issue. Hopefully that might help you out as well?
Upvotes: 4