I was trying to follow this guide to make a simple python game and decided to use docker to manage the versions and stuff.
but when running the docker image i get the following error:
The path /dev/dri/ cannot be opened or is not available
The path /dev/dri/ cannot be opened or is not available
The path /dev/dri/ cannot be opened or is not available
The path /dev/dri/ cannot be opened or is not available
Traceback (most recent call last):
File "/app/main.py", line 32, in <module>
main()
File "/app/main.py", line 13, in main
with tcod.context.new_terminal(
File "/usr/local/lib/python3.9/site-packages/tcod/_internal.py", line 29, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/tcod/context.py", line 616, in
new_terminal
return new(
File "/usr/local/lib/python3.9/site-packages/tcod/context.py", line 569, in new
_check_warn(error)
File "/usr/local/lib/python3.9/site-packages/tcod/_internal.py", line 75, in
_check_warn
if _check(error) > 0:
File "/usr/local/lib/python3.9/site-packages/tcod/_internal.py", line 62, in _check
_raise_tcod_error()
File "/usr/local/lib/python3.9/site-packages/tcod/_internal.py", line 56, in
_raise_tcod_error
raise RuntimeError(ffi.string(lib.TCOD_get_error()).decode("utf-8"))
RuntimeError: libtcod 1.20.1 libtcod/src/libtcod/renderer_sdl2.c:902
Could not initialize SDL:
dummy not available
Video driver 'x11' is not working.
Video driver 'wayland' is not working.
Video driver 'KMSDRM' is not working.
Video driver 'KMSDRM_LEGACY' is not working.
Video driver 'dummy' is not working.
my dockerfile
# syntax=docker/dockerfile:1
FROM python:3.9.0
WORKDIR /app
COPY requirements.txt requirements.txt
RUN python3 -m pip install -r requirements.txt
COPY . .
CMD [ "python3", "main.py", "--host=0.0.0.0"]
the requirements are very simple
tcod
numpy
finally my main.py
#!/usr/bin/env python3
import tcod
def main() -> None:
screen_width = 80
screen_height = 50
tileset = tcod.tileset.load_tilesheet(
"assets/dejavu10x10_gs_tc.png", 32, 8, tcod.tileset.CHARMAP_TCOD
)
with tcod.context.new_terminal(
screen_width,
screen_height,
tileset=tileset,
title="Yet Another Roguelike Tutorial",
vsync=True,
) as context:
root_console = tcod.Console(screen_width, screen_height, order="F")
while True:
root_console.print(x=1, y=1, string="@")
context.present(root_console)
for event in tcod.event.wait():
if event.type == "QUIT":
raise SystemExit()
if __name__ == "__main__":
main()
I dont know if it helps but im on ubuntu 20.04
im guessing that it has something to do with the drivers but im not really sure how to solve this since im new to python and docker. i tried using other python versions for the image but it also fails
EDIT: the code works fine outside docker