20

I have decided to do some programming in Kivy cross platform and installed Kivy on my computer successfully. The problem is that when I run my code, I get this error:

[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
[INFO              ] [Factory     ] 179 symbols loaded
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO              ] [OSC         ] using <thread> for socket
[INFO              ] [Window      ] Provider: sdl2
[INFO              ] [GL          ] GLEW initialization succeeded
[INFO              ] [GL          ] OpenGL version <b'1.1.0'>
[INFO              ] [GL          ] OpenGL vendor <b'Microsoft Corporation'>
[INFO              ] [GL          ] OpenGL renderer <b'GDI Generic'>
[INFO              ] [GL          ] OpenGL parsed version: 1, 1
[CRITICAL          ] [GL          ] Minimum required OpenGL version (2.0) NOT found!

OpenGL version detected: 1.1

Version: b'1.1.0'
Vendor: b'Microsoft Corporation'
Renderer: b'GDI Generic'

Try upgrading your graphics drivers and/or your graphics hardware in case of problems.

The application will leave now.

And this error box pops out:

Kivy Fatal Error

I have checked OpenGL version of my GPU via GPU Caps Viewer verifying me up to OpenGL Version 2.1, but Kivy somehow doesn't detect OpenGL 2.1 and defaults to GDI Generic from Microsoft instead. I did some research on internet and found out that best way to resolve this problem is to update your graphical card's driver from your graphical card manufacturer, but this didn't work in my case.

I have updated my graphic drivers (I am running NVIDIA GeForce GT 435M on 64-bit Windows 8).

My question is: Is there a way to let Kivy switch from GDI Generic driver to NVIDIA driver? Or is there a problem somewhere else?

Misa Lazovic
  • 2,805
  • 10
  • 32
  • 38
Matic Brank
  • 207
  • 1
  • 2
  • 6
  • 1
    Did you update your graphics driver through Windows' built-in update function, or did you visit the NVidia website, manually downloaded a driver installer there and executed that? When it comes to OpenGL **always** do the later, because for some reason Microsoft strips the OpenGL parts from drivers installed through Windows' automatic driver installation process. – datenwolf Jan 24 '16 at 09:35

15 Answers15

19

If you still have the problem try this:

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

It worked for me (Windows 10, OpenGL 3.1, Python 3.6).

wovano
  • 4,543
  • 5
  • 22
  • 49
Jack Newbile
  • 191
  • 1
  • 4
15

On windows 7 pro 32bit adding Config.set('graphics', 'multisamples', '0') solved the error for me. (Update: This is also works on Windows 10.)

import kivy 
kivy.require('1.9.1') # replace with your current kivy version !

from kivy.app import App
from kivy.uix.label import Label

# add the following 2 lines to solve OpenGL 2.0 bug
from kivy import Config
Config.set('graphics', 'multisamples', '0')


class MyApp(App):

    def build(self):
        return Label(text='Hello world')

if __name__ == '__main__':
    MyApp().run()

After the change, the OpenGL version is reported correctly:

[INFO ] [GL ] GLEW initialization succeeded

[INFO ] [GL ] OpenGL version <2.1.0 - Build 8.15.10.2281>

naktinis
  • 3,957
  • 3
  • 36
  • 52
576i
  • 7,579
  • 12
  • 55
  • 92
  • Note that the kivy Config lines should be at the top of the script, before any other Kivy import, else it won't work! Another way is to use Sergei's approach to modify kivy config file, [see below](https://stackoverflow.com/a/43305802). – gaborous Dec 25 '17 at 13:18
  • 1
    Does this still work for folks? I tried it on Windows 10 and it didn't work, but Jack Newbile's answer below did. – Dave Mackey Jul 06 '19 at 05:28
11

I use Python 3.6 and Windows 8.1. Works on Windows 10 also.
this solution solve the problem in most cases :
.
1. Right click on This PC then open Properties .
2. Go to Advanced system settings .
3. Click on Environment Variables .
4. Click on New in User variables for --- .
5. Put KIVY_GL_BACKEND in Variable name .
6. Put angle_sdl2 in Variable value .
7. Restart Python .

Here is a YouTube video showing these steps : https://www.youtube.com/watch?v=ATK9w2AiDeM

uncoded0123
  • 167
  • 2
  • 13
Khaled Dallah
  • 111
  • 1
  • 4
9

Angle backend for py3.5+

pip install kivy.deps.angle 
set KIVY_GL_BACKEND=angle_sdl2

It works perfectly on windows 10 and its solution for above problem. Multisample won't work in my case

Yash
  • 6,644
  • 4
  • 36
  • 26
  • 1
    can launch pycharm after setting that KIVY_GL_BACKEND environment variable and worked. Can that be set from within the python code? – tmx May 08 '18 at 22:08
4

Change multisamples key value in config file (%HOMEPATH%\.kivy\config.ini for me) from multisamples = 2 to multisamples = 0.

Sergei K
  • 51
  • 3
3

First of all, I am using Python 3.7.

I followed the below instruction first:

  1. Right click on This PC then open Properties.
  2. Go to Advanced system settings.
  3. Click on Environment Variables.
  4. Click on New in User variables for ---.
  5. Put KIVY_GL_BACKEND in Variable name.
  6. Put angle_sdl2 in Variable value .
  7. Restart Python

Then I run the following in my IDE on Windows 10 and it worked for me

from kivy import Config
Config.set('graphics', 'multisamples', '0')
import os
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
import kivy
from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):
    def build(self):
        return Label(text="Tech With Me")

if __name__== "__main__":
    MyApp().run()
Oleksii Filonenko
  • 1,551
  • 1
  • 17
  • 27
2

This seems to be a known bug in the current version of kivy and is already reported in their issue tracker. So I guess there is no (easy) way to solve this problem. Switching back to an older version might help.

BDL
  • 21,052
  • 22
  • 49
  • 55
1

put this in your code and it ll work

from kivy import Config

Config.set('graphics', 'multisamples', '0')
slfan
  • 8,950
  • 115
  • 65
  • 78
0

For old embedded graphics like Intel GMA 965 at Windows 10:

in addition to setting multisamples to 0,
try fix tool by pal1000 https://github.com/pal1000/save-legacy-intel-graphics

(a bit more info at https://community.khronos.org/t/i-have-opengl-3-1-but-kivy-says-that-i-have-only-1-1/103980/6 and https://stackoverflow.com/a/57406551/11284684)

0

I was packaging my application with pyinstaller and none of the above worked on my windows 10 machine to run a Python App.

After searching further, This is what that solved my problem.

Navigate to dist folder where your application (.exe) is. Delete the .manifest file, named after your App name i.e (myappname.exe.manifest).

The Error should be gone now, As old as from the 90's machines, OPenGL will be found!

0

Try adding an environment variables for user Variable name - KIVY_GL_BACKEND variable value- angle_sd12

I have seen this error come up when you install kivy on a virtual environment in pip or conda.

0

As a quick workaround, try this.

# Keep these two lines until you find what the real solution is
import os
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'

from kivy.app import App
App().run()
tripleee
  • 175,061
  • 34
  • 275
  • 318
  • 1
    Is this mis-formatted code-only or weirdly formatted prose? Either way, it could benefit from some additional explanation in prose. – Yunnosch Jun 01 '20 at 06:38
  • 2
    At least two other answers seem to have suggested this, alongside more detail, and over four years ago. – Jeremy Caney Jun 01 '20 at 06:57
0

I had the same problem as said above. Simply adding angle_sdl2 to the user environment variable was enough to solve the problem—it worked for me.

loved.by.Jesus
  • 2,266
  • 28
  • 34
Bos
  • 1
0

None of above works for me. When I use: os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'

I get an error: sdl2 - RuntimeError: b'Could not initialize OpenGL / GLES library'

When I use only: Config.set('graphics', 'multisamples', '0')

I get:

OpenGL version detected: 1.1

Version: b'1.1.0'
Vendor: b'Microsoft Corporation'
Renderer: b'GDI Generic

It happens on two out of six mashines where my App.exe is installed. I've tried to install the newest packages kivy 1.11.1 and kivy.deps.sdl2 2.0.0 and the resoult is the same. Deleting .exe.manifest file doesn't work too.

ForyszeP
  • 143
  • 1
  • 15
-1

I remember having worked around this bug by changing the color depth of the screen (from 16bit to 32bit or vice versa).

sdementen
  • 412
  • 6
  • 8
  • This did not work for me on windows 7 pro 32 bit: I get the error message on 32bit, on 16bit I get "unable to get a window" instead – 576i May 21 '16 at 12:12