kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
https://kivymd.readthedocs.io
MIT License
2.14k stars 655 forks source link

Unable to specify kivymd as a requirement in a Docker container #1710

Closed MariyaSha closed 2 weeks ago

MariyaSha commented 2 weeks ago

Hi community! I'm working on a new tutorial for a KivyMD app that runs in a Docker container. I can run it perfectly in an Anaconda environment, but when it comes to containerizing it, I can't seem to find an existing solution online.

I've generated the generic Docker necessities with: docker init The Python version I selected is 3.10, my operating system is WSL2, and the current content of my requirements.txt file is simply:

kivy
https://github.com/kivymd/KivyMD/archive/master.zip

(please note, I've tried many variations of specifying the requirements, including detailed versions and github clones)

When I run my container, I get the following error message: image

This error is triggered by the very first line of code: from kivymd.app import MDApp And I believe that it has to do with a lack of permissions for Kivy to create new directories within the container environment. I wonder if anyone can help me with a workaround? I'd really appreciate it as it's been a while since I've featured KivyMD on my channel! :)

BTW: I also tried skipping requirements.txt and installing KivyMd directly from the Dockerfile with: RUN pip install kivymd But unfortunately, I'm getting the same error.

Thank you so much in advance! Mariya

eisenheimjelid commented 2 weeks ago

Which is the Docker base image that you are using? Did you try with Buildozer?

eisenheimjelid commented 2 weeks ago

Another possible idea: https://github.com/kivymd/KivyMD/issues/1070. I see you are using python:3.10-slim. Try with 3.12.4-bookworm (a newer version and complete; the -slim versions usually don´t have all the libraries or compilation headers, so it is a better idea to use a full image).

MariyaSha commented 2 weeks ago

Thank you @eisenheimjelid! I just tried installing 3.12.4-bookworm but unfortunately it returns the same error.

The base image is automatically set by docker init when choosing Python as the application platform. Inside the Dockerfile, it looks like this:

ARG PYTHON_VERSION=3.10
FROM python:${PYTHON_VERSION}-slim as base

(therefore the -slim tag you noticed earlier)

I've used Buildozer before to create .apk for Android, but the app I'm building is meant to run in a desktop environment rather than a mobile one. Just struggling with getting KivyMD installed inside the container (and it looks like Kivy as well).

Thanks again for your help!

MariyaSha commented 2 weeks ago

Solved by lovely absurdi57 from X:

Dockerfile: GP8fkxkWwAAW5yD

Sample Python File: pyfile

Requirements:

kivy
https://github.com/kivymd/KivyMD/archive/master.zip

X Server for Windows (allows GUIs in WSL2): How to Install Tutorial: https://rushichaudhari.github.io/posts/2020-08-19-dockerguiwsl/ Server Repo: https://github.com/marchaesen/vcxsrv

Credit: pastebin.com/C3fP6pVK and absurdi57, of course!