community icon indicating copy to clipboard operation
community copied to clipboard

Add note about VMs and setting `KIVY_GL_BACKEND` to `angle_sdl2` to documentaton

Open maltfield opened this issue 5 years ago • 1 comments

Is your feature request related to a problem? Please describe.

The kivy documentation doesn't work if you're in a VM.

In Windows running as a VM, the following must be added to the top of the source code to execute kivy examples:

import os
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'

Moreover, in order to build the app to a windows executable in a Windows VM, the environment variable must also be set since PyInstaller won't check the environment variable set in the above script. This can be done in PowerShell with (see https://github.com/kivy/kivy/issues/6906):

$env:KIVY_GL_BACKEND="angle_sdl2"

I'm sure that many developers choose kivy specifically because it supports many platforms, so it's likely that developers will be spinning up VMs to test their applications in a platform that they don't have. For me, I encountered this issue when testing my app in a Windows VM. My primary OS is linux.

Please update the documentation to make it clear the changes that are necessary for apps to compile in a Windows VM.

Describe the solution you'd like

Please update this page https://kivy.org/doc/stable/installation/installation-windows.html

With the following text in a notebox or its own section

Note: When Windows is running in a virtual machine, you may encounter the following error:

  "Minimum required OpenGL version (2.0) NOT found!"

This is an issue with the VM's graphics driver. One solution is to switch the kivy gl backend to angle by adding the following three lines to the very top of your code, before kivy is imported:

  import platform, os
  if platform.system() == 'Windows':
      os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'

Secondly, please also update this page https://kivy.org/doc/stable/guide/packaging-windows.html

With the following text in a notebox or its own section

Note: When Windows is running in a virtual machine, your resulting executable may fail to run with the following error:

   "Unable to find any valuable Window provider ... Unable to get a Window, abort."

This is an issue with the VM's graphics driver and the fact that PyInstaller will not check your source code for changes to KIVY_GL_BACKEND made with os.environ. To fix this issue, please set your KIVY_GL_BACKEND environment variable to 'angle_sdl2' in on your command line before executing python's pyinstaller module. For example, this can be done in PowerShell in Windows 10 with the following command:

  $env:KIVY_GL_BACKEND="angle_sdl2"

Describe alternatives you've considered

Spending a long time googling for the solution, only to find scattered & unclear unoffical answers buried in github issues and stackoverflow questions.

maltfield avatar May 31 '20 13:05 maltfield

Strange, I have the exact opposite problem: setting KIVY_GL_BACKEND="angle_sdl2" will prevent me from running Kivy in my Win10 VM. Removing it lets Kivy use the glew backend without problem and everything runs fine.

I was wondering what is the motivation for modifying KIVY_GL_BACKEND, isn't Kivy supposed to search & choose the best available backend?

francisjeanneau avatar Jan 26 '24 19:01 francisjeanneau