导入 ursina 时,GitLab 管道失败并出现"ScreenInfoError: No enumerators available"



我试图在使用ursina的软件上运行测试,这是一个python游戏引擎。当导入ursina时,没有找到图形设备,管道失败并出现错误。是否有针对此类场景的标准缓解措施,即"模拟"的标准方法;GitLab流水线中的屏幕?

我当前的GitLab管道看起来像这样:

image: python:latest
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip
- env/
before_script:
- pip install virtualenv
- virtualenv env
- source venv/bin/activate
- pip install -r requirements.txt
test:
script:
- python ...

在导入ursina的文件上运行测试时,我得到的错误是:

======================================================================
ERROR: foobar.test.test_foobar (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: foobar.test.test_foobar
Traceback (most recent call last):
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/support/unix_connect.py", line 105, in get_socket
s = _get_unix_socket(address)
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/support/unix_connect.py", line 84, in _get_unix_socket
s.connect(address)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/support/unix_connect.py", line 109, in get_socket
s = _get_tcp_socket(host, dno)
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/support/unix_connect.py", line 79, in _get_tcp_socket
s.connect((host, 6000 + dno))
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/builds/johndoe/foo/venv/lib/python3/site-packages/ursina/window.py", line 50, in __init__
resolution = Xlib.display.Display().screen().root.get_geometry()
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/display.py", line 89, in __init__
self.display = _BaseDisplay(display)
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/display.py", line 71, in __init__
protocol_display.Display.__init__(self, *args, **keys)
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/protocol/display.py", line 90, in __init__
self.socket = connect.get_socket(name, protocol, host, displayno)
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/support/connect.py", line 87, in get_socket
return mod.get_socket(dname, protocol, host, dno)
File "/builds/johndoe/foo/venv/lib/python3/site-packages/Xlib/support/unix_connect.py", line 113, in get_socket
raise error.DisplayConnectionError(dname, str(val))
Xlib.error.DisplayConnectionError: Can't connect to display ":0": [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/local/lib/python3/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/builds/johndoe/foo/foobar/test/test_foobar.py", line 4, in <module>
from foobar.src.foobar import foobar
File "/builds/johndoe/foo/foobar/src/foobar.py", line 5, in <module>
from RubiksCubeUtils.CustomDecorators import with_move_attribute
File "/builds/johndoe/foo/RubiksCubeUtils/CustomDecorators.py", line 3, in <module>
from ursina import invoke
File "/builds/johndoe/foo/venv/lib/python3/site-packages/ursina/__init__.py", line 10, in <module>
from ursina.window import instance as window
File "/builds/johndoe/foo/venv/lib/python3/site-packages/ursina/window.py", line 367, in <module>
instance = Window()
File "/builds/johndoe/foo/venv/lib/python3/site-packages/ursina/window.py", line 59, in __init__
self.screen_resolution = [get_monitors()[0].width, get_monitors()[0].height]
File "/builds/johndoe/foo/venv/lib/python3/site-packages/screeninfo/screeninfo.py", line 32, in get_monitors
raise ScreenInfoError("No enumerators available")
screeninfo.common.ScreenInfoError: No enumerators available

在linux容器中,我安装了libxrand库。对于基于Debian的发行版(ubuntu),使用

apt install -y libxrandr2

相关内容

  • 没有找到相关文章

最新更新