添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
import OpenGL.GLUError:
Error:
Traceback (most recent call last): File "d:\Code\Python\OpenGL\OpenGL.py", line 1, in <module> import OpenGL.GL File "d:\Code\Python\OpenGL\OpenGL.py", line 1, in <module> import OpenGL.GL ModuleNotFoundError: No module named 'OpenGL.GL'; 'OpenGL' is not a package
Larz60+ write Jul-12-2023, 02:08 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
When Python executes this in your program:
import OpenGL.GL
It searches the python path for "OpenGL.py". This should be found in a folder that was added to your "python311/Lib/site-packages" (or whatever version of Python or whatever virtual environment you are using) folder when you ran pip install. But before it looks in "python311/Lib/site-packages" in looks for the OpenGL.py in the current working directory, usually the same directory as the program you are running. If it finds the file there, it imports that file, not the package you installed using pip.
If you want to use OpenGL, you should not create any files named OpenGL.py. You can use "Open_GL.py" or "opengl_test.py" or any name that does not match the name of modules you import in your program.