Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Bug: AttributeError: module 'ctypes' has no attribute 'util' in glcontext.py, Line 58 #286

Open
ChepeAicrag opened this issue Jun 3, 2021 · 1 comment

Comments

@ChepeAicrag
Copy link

Describe the bug

I am working in colab, and I am following the tutorial from Using OpenGL with Colab Cloud GPUs. It is important to mention that the version used is Python 3.7.10.

When at the time of import

from lucid.misc.gl.glcontext import create_opengl_context

I get this traceback:

----> 1 from lucid.misc.gl.glcontext import create_opengl_context
      2 
      3 # Now it's safe to import OpenGL and EGL functions
      4 import OpenGL.GL as gl
      5 

/usr/local/lib/python3.7/dist-packages/lucid/misc/gl/glcontext.py in <module>()
     56 # [2] https://devblogs.nvidia.com/linking-opengl-server-side-rendering/
     57 # [3] https://bugs.python.org/issue9998
---> 58 _find_library_old = ctypes.util.find_library
     59 try:
     60 

AttributeError: module 'ctypes' has no attribute 'util'

Solution

The reason for this is that import ctypes does not import ctypes.util by default anymore in newest python. Therefore after import ctypes there should be an extra line import ctypes.util.

Now the imports in the file glcontext.py with the import added, it would be as follows:

import ctypes
import ctypes.util
from ctypes import pointer
import os

Or also import the other way:

import ctypes
from ctypes import pointer, util
import os

And with that import will correct the problem.

@zzj-eric
Copy link

Hello, when i do as you said, i get a new problom.
Unable to load OpenGL libraries. Make sure you use GPU-enabled backend.
Press "Runtime->Change runtime type" and set "Hardware accelerator" to GPU.
ImportError: 'Unable to load EGL library' None, 126, None, 'libEGL.so', 'libEGL.so'
Do you know how to solve it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants