# GLEW could not be initialized: Missing GL version - VTK under Python Windows

**URL:** https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598
**Category:** Support
**Created:** [November 6, 2020, 5:28pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598 "2020-11-06T17:28:21Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![silverthorn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@silverthorn](https://discourse.vtk.org/u/silverthorn)
#### Post date: [November 6, 2020, 5:28pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/1 "2020-11-06T17:28:21Z")

</div>

This is an issue that I have been having for some days and have not found a solution under various Python, VTK and OpenGl versions . I have tried many things - too many to list. I saw this under anaconda but have now given up on that to try a fresh install running Python from the command prompt. I have reduced my system to what I think is the simplest level in order to isolate the issue :

So I am running Python 3.8 with VTK 9.0.1 and PyOpenGL 3.1.5 with PyOpenGL-accelerate 3.1.5

It seems that VTK does not work with Python 3.9 yet.

Running a simple example (below) I get the following error when the command window.Render() is executed :

2020-11-06 17:14:33.758 ( 0.313s) []vtkWin32OpenGLRenderWin:635 ERR| vtkWin32OpenGLRenderWindow (0000020DA5C81D40): failed to get wglChoosePixelFormatARB  
2020-11-06 17:14:33.790 ( 0.345s) []vtkWin32OpenGLRenderWin:713 ERR| vtkWin32OpenGLRenderWindow (0000020DA5C81D40): failed to get valid pixel format.  
2020-11-06 17:14:33.802 ( 0.357s) []vtkOpenGLRenderWindow.c:569 ERR| vtkWin32OpenGLRenderWindow (0000020DA5C81D40): GLEW could not be initialized: Missing GL version

This message is now very familiar to me !! but what does it mean ?  
.  
Is this a graphics card compatibility issue ? How can I check and what can I do to fix that ??

What can I do to move on ? What other information do I need to supply ?

Script :

import vtk  
import time

cone = vtk.vtkConeSource()

mapper = vtk.vtkPolyDataMapper()  
mapper.SetInputConnection(cone.GetOutputPort())

actor = vtk.vtkActor()  
actor.SetMapper(mapper)

renderer = vtk.vtkRenderer()  
renderer.AddActor(actor)  
renderer.ResetCamera()  
camera = renderer.GetActiveCamera()

window = vtk.vtkRenderWindow()  
window.AddRenderer(renderer)

azimuth = 0  
while 1:  
window.Render()  
if azimuth \>= 360:  
azimuth = 0  
azimuth += 0.1  
camera.Azimuth(azimuth)

```
time.sleep(0.1) 

```

Thank in anticipation - Jerry

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [November 7, 2020, 12:30pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/2 "2020-11-07T12:30:42Z")

</div>

Yea, reduce it further to the very bare minimum. (VTK + Python wrappers)

How did you install VTK? Built from source? anaconda?

You shouldn’t need PyOpenGL or any such package to use VTK since the library comes bundled with its own OpenGL loader wrapped up in [`vtkglew`](https://github.com/Kitware/VTK/tree/master/ThirdParty/glew/vtkglew).

---

<div class="post-metadata">

### Author: ![silverthorn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@silverthorn](https://discourse.vtk.org/u/silverthorn)
#### Post date: [November 7, 2020, 1:58pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/3 "2020-11-07T13:58:37Z")

</div>

Spotted the PyOpenGl thing today and uninstalled it - still same message.

VTK was installed with pip install vtk but I note now that this picked up a downloaded wheel file vtk-9.0.1-cp38-cp38-win\_amd64.whl which I downloaded when trying to fix this under Anaconda. However, I think this is correct - no ?

I’ve been looking at the VTK source code and the line numbers and messages all add up to initglew() failing. Can’t find the source code for that anywhere ??

Thanks for looking !!

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [November 7, 2020, 2:04pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/4 "2020-11-07T14:04:21Z")

</div>

> I’ve been looking at the VTK source code and the line numbers and messages all add up to initglew() failing. Can’t find the source code for that anywhere ??

[Here](https://gitlab.kitware.com/vtk/vtk/blob/e276e4cfdf87a37a417b7451fe07c8ac792e456f/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx#L781)

Somehow the version you’ve installed has OpenGL conflicts.  
Clear pip’s, conda’s cache and try again. Anaconda often installs its own shared system libraries and this might have lead to a mix up.

Can you try to build from source? IMHO, that’s the best way

---

<div class="post-metadata">

### Author: ![silverthorn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@silverthorn](https://discourse.vtk.org/u/silverthorn)
#### Post date: [November 7, 2020, 2:20pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/5 "2020-11-07T14:20:31Z")

</div>

I’ll try but there must be something left buried in windows somewhere as Anaconda has been uninstalled and the remaining directories deleted before I started from scratch.

I will start again with a new user environment and try this all again. Cheers !! Then it’s a new windows installation !! hey ho !!

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [November 7, 2020, 2:27pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/6 "2020-11-07T14:27:15Z")

</div>

yep, with windows, gotta do that reinstall.

I manage my VTK stuff in a neatly sandboxed Linux system within ugly windows. Check out WSL! It’s also a breeze to setup Visual Studio to work with the sandboxed Linux environment.

Can do all kinds of memory debugging/profiling shenanigans from VS for a library running in Linux.  
Best things of both worlds!

---

<div class="post-metadata">

### Author: ![silverthorn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@silverthorn](https://discourse.vtk.org/u/silverthorn)
#### Post date: [November 7, 2020, 2:48pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/7 "2020-11-07T14:48:45Z")

</div>

Annoyingly this is a new machine (maybe the root cause of my issues) with a fresh windows and nice fast SSD !!! I use LINUX at work but all my home machines are windows. Yet to make the change - but I guess it’s coming. The latest windows version is very buggy (doesn’t remember passwords anymore …).

Just trying to get a new user and discovered that the USER variable isn’t being written properly - so working on that. Hopefully I’ll be able to report that the issue I have is fixed AND why !!

---

<div class="post-metadata">

### Author: ![silverthorn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@silverthorn](https://discourse.vtk.org/u/silverthorn)
#### Post date: [November 7, 2020, 6:45pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/8 "2020-11-07T18:45:58Z")

</div>

Hi, update - vtk 9.0.1 successfully make’d and built into a folder in my appdata folder (along with python).

But python can’t find the newly built vtk … (ModuleNotFoundError: No module named ‘vtk’)

so how do I link it to Python - is there a .h file or something similar that I need to add to the path. If I try pip it automatically finds the same .whl file from the internet that fails with the above message.

Finding this difficult - to do but also to understand what is going on.

Thanks in advance.

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [November 8, 2020, 1:31am UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/9 "2020-11-08T01:31:31Z")

</div>

You’ve to add the path to VTK’s site-packages to `PYTHONPATH`

---

<div class="post-metadata">

### Author: ![silverthorn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@silverthorn](https://discourse.vtk.org/u/silverthorn)
#### Post date: [November 8, 2020, 10:41am UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/10 "2020-11-08T10:41:48Z")

</div>

There is no site-packages folder and there is no variable PYTHONPATH !

I followed all the instructions from this page :

[https://vtk.org/Wiki/VTK/Configure\_and\_Build#On\_Windows\_5](https://vtk.org/Wiki/VTK/Configure_and_Build#On_Windows_5)

Obviously I am doing something wrong !

There is a site-packages folder in the Python directory under Lib - should I move VTK build files there ? and which ones …

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [November 9, 2020, 4:29am UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/11 "2020-11-09T04:29:19Z")

</div>

No, don’t move anything. Looks like the build did not generate wrappers.

While configuring cmake, check these 3 variables that enable python wrappers

`Python3_EXECUTABLE` this is automatically found  
`VTK_PYTHON_VERSION` automatically set to match above python  
`VTK_WRAP_PYTHON` is `OFF` by default. Flip it.

After the `configure`, `generate`, `build`, `install` process, a `site-packages` directory should be there under `CMAKE_INSTALL_DIR/lib`

For python on windows and its hacks, [this thread](https://stackoverflow.com/a/4855685/12058620) and [this documentation](https://docs.python.org/3/using/windows.html#configuring-python) should help you.

If VTK C++ works fine for you and this is a python wrapper issue, please start a new thread 🙂

---

<div class="post-metadata">

### Author: ![silverthorn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@silverthorn](https://discourse.vtk.org/u/silverthorn)
#### Post date: [November 12, 2020, 2:19pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/12 "2020-11-12T14:19:13Z")

</div>

Things have moved on in this investigation. I failed to build VTK from scratch as none of the above resolutions worked. My suspicion being a bad windows installation.

I have now rebuilt both my laptop a Medion Akoya win 10 Home and my desktop a DELL Optiplex 9010 with win 10 Pro.

This problem does not occur on my laptop under Python 3.8 VTK 9.01 but still persists on the DELL. All other Python programs that I am developing on the DELL are fine.

It is my conclusion that the graphics card in the DELL is incompatible with VTK. As per my original post. The graphics card is build into the motherboard and I am looking to buy an extension card replacement but it;'s a bit tight in the case for duel screen versions (another problem). I read somewhere that MESA can be used as a graphics emulator but I can’t now find where I read that.

Can anyone point me towards either a solution to this - or a workaround please.

This is all very frustrating as I am new to Python and had bought this machine to make progress ij my personal development. This issue has been very complicated to work through - including the discovery of a bug in the vtk Render() command which I have posted in GitHub separately :

[Python / VTK script crashes in windows](https://stackoverflow.com/questions/64775372/python-vtk-script-crashes-in-windows-when-application-window-is-opened-or-move/64794849#64794849)

but at least I can work on my VTK project on my laptop now.

For anyone who can help the DxDiag utility produces the following report on my system :

* * *

## Display Devices

```
       Card name: Intel(R) HD Graphics
    Manufacturer: Intel Corporation
       Chip type: Intel(R) HD Graphics Family
        DAC type: Internal
     Device Type: Full Device (POST)
      Device Key: Enum\PCI\VEN_8086&DEV_0102&SUBSYS_052C1028&REV_09
   Device Status: 0180200A [DN_DRIVER_LOADED|DN_STARTED|DN_DISABLEABLE|DN_NT_ENUMERATOR|DN_NT_DRIVER] 

```

Device Problem Code: No Problem  
Driver Problem Code: Unknown  
Display Memory: 1664 MB  
Dedicated Memory: 32 MB  
Shared Memory: 1632 MB  
Current Mode: 1680 x 1050 (32 bit) (60Hz)  
HDR Support: Not Supported  
Display Topology: Extend  
Display Color Space: DXGI\_COLOR\_SPACE\_RGB\_FULL\_G22\_NONE\_P709  
Color Primaries: Red(0.649414,0.334961), Green(0.283203,0.605469), Blue(0.151367,0.073242), White Point(0.312500,0.329102)  
Display Luminance: Min Luminance = 0.500000, Max Luminance = 270.000000, MaxFullFrameLuminance = 270.000000

---

<div class="post-metadata">

### Author: ![silverthorn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@silverthorn](https://discourse.vtk.org/u/silverthorn)
#### Post date: [November 12, 2020, 5:42pm UTC](https://discourse.vtk.org/t/glew-could-not-be-initialized-missing-gl-version-vtk-under-python-windows/4598/13 "2020-11-12T17:42:50Z")

</div>

Looking at the VTK documentation :  
[[https://vtk.org/Wiki/VTK/FAQ#What\_Graphics\_Cards\_work\_with\_VTK](https://vtk.org/Wiki/VTK/FAQ#What_Graphics_Cards_work_with_VTK)]([http://VTK](http://VTK) graphics card compatibility)

I note that VTK should work with OpenGl versions 2.1 and above. I have checked my compatibility and see that the laptop is compatible with GL version 4.3 (this works) and that my desktop is compatible only with GL version 3.1 (this does not). So something is wrong ! Either the VTK documentation is out of date or I am still not linking to the OpenGL driver for some reason.

The clue is “GLEW could not be initialized: Missing GL version” but I can’t see the issue.
