PyOpenGL isnt a package - python

Trying to run a basic pygame based PyOpenGL window and it returns an error.
I have reinstalled them both from https://www.lfd.uci.edu/~gohlke/pythonlibs/
Code:
import pygame as pg
from OpenGL.GL import *
Error:
ModuleNotFoundError: No module named 'OpenGL.GL'; 'OpenGL' is not a package
Tried running it, expected a window with a blue/grey background. recieved an error in VS Code terminal and anger

cgohlke's comment was right, the file I was using was called OpenGL.py changed the name and it worked fine

Related

How to fix my non-working pygame library?

Problem is whenever I try to run any python file with import pygame in it, it does not work. It always results in a ModuleNotFoundError: No module named 'pygame', though I do have pygame library installed.
I don't know if this is part of the problem but my pygame package is for some reason in \Lib\site-packages.

importing turtle module in VS Code gives ModuleNotFoundError: 'tkinter'

I am trying to import turtle module. but it shows me module name 'tkinter' is not found. although it is a built-in module.and i didnt import it directly.(i think turtle module imports tkinter for me.)
I tried changing the path for Python in VS Code by clicking the bottom left option is status bar.
other modules are getting imported(import random, etc)
I have attached the screenshot of the code and error i am getting.
Please HELPPP!!!!
It can also be an import error that you facing with you IDE (VS Code). Try changing the target exe to the python interpreter in your virtual environment. You can learn more about this, by visiting the link below:
https://medium.com/nerd-for-tech/import-errors-in-python-no-module-named-module-name-for-vs-code-887d1f78cf02

ImportError; Issue installing Reportlab 3.4 with Python 3.5 in PyCharm

I am trying to run Reportlab 3.4 in Python 3.5 in PyCharm
I installed via Project Interpreter (and I also installed via Terminal). When I try to import the following packages
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.pagesizes import portrait
from reportlab.platypus import Image
I get the following error:
ImportError: No module named 'reportlab.pdfgen'; 'reportlab' is not a package
It seems that several people had this issue a few years back but I cannot find a recent example of this happening.
Any insight would be appreciated.
I had the same problem. The import statements worked if I typed them directly into the interpreter, but if I tried to execute my program from a file I got import errors stating: ImportError...'reportlab' is not a package. These import conflicts arise if you name your script reportlab.py, you just have to rename it to something else.

`import pygame` shows no errors even when pygame is not installed

I've been installing, uninstalling, and reinstalling pygame because there's a program that I've been trying to run (that uses pygame). However whenever I've installed pygame, the program doesn't work.
Traceback (most recent call last):
File "C:\Users\Ryan\Desktop\en\snake.py", line 28, in <module>
class Segment(pygame.sprite.Sprite):
AttributeError: 'module' object has no attribute 'sprite'
(Pygame is not installed when I receive this error supposedly)
What's really confusing me though is that when I type import pygame in normally in IDLE, I get no errors even when I just uninstalled it.
Windows 8 64 bit
Python 3.4.3
Pygame-1.9.2a0.win32-py3.4.msi (pygame file name)
Python is installed on C Drive (C:\Python34)
Whenever Pygame was installed, it was on the D drive
Have Python directory added to Path
Here's a screenshot of a video tutorial I was following, and it shows there are two installation paths. And here's mine, which only shows one path. I'm not sure if this is a big deal, but I just want to be sure.
Open your python interpreter and import pygame
Then you can print pygame to see exactly what is being loaded, should be something like: <module 'pygame' from '/Library/Python/2.7/site-packages/pygame/__init__.py'>
(repeat the above step until it fails importing pygame),
Close your prompt and install pygame. Try executing it again. Should the problem persist, you can edit some file in the game you are trying to run and add two lines: import sys and print sys.path and check the list of paths to make sure that there is not some other pygame installation somewhere bundled with the game that is being used instead of your installed pygame.
Modification of Josep Valls's answer:
You will need to change sys.path. This can be accomplished with the following code:
import sys
sys.path.append('''directory where pygame is''')
import pygame
The sys.path variable tell Python where to look for modules. By adding a path by append, you are telling Python to look for imported modules there. After that pointer is made, you can import pygame.

Import error: Module use of python27.dll conflicts with this version of python

import sys
sys.path.insert(1,"C:/Users/ravir_000/Desktop/python_CS105/python_CS105/Python27/Lib/site-packages")
import math
import random
import pygame
from pygame.locals import *
pygame.init()
How do you get rid of the error? Import error: Module use of python27.dll conflicts with this version of python. I was working on this a few hours ago and it was working fine. When I got into class it started giving me this error. I have tried to install/reinstall pyscripter and pygame but it still does not work. I am sure that my path to pygame is correct. Any ideas?
You are trying to use a pygame distribution that is for python 2.7 with a different version of python.
You should download and use the appropriate version.
If installed correctly, there will be no need for sys.path.insert.

Categories