#๐ pygame problem
109 messages ยท Page 1 of 1 (latest)
@fiery geode
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Did you pip install pygame?
Try to type, "pip install pygame" in your terminal or command prompt and then rerun your code.
Requirement already satisfied
Try, "pip uninstall pygame" and then "pip install pygame"
still not working
if your on vscode restart, pycharm restart.
that might fix the issue
okay
That's in your IDE, not when you run the program. It means your IDE checks libs for a different interpreter than you run your code with (and run pip with)
okay
("Import" pygame" could not be resolved" is IDE thing,
code running would be "ModuleNotFoundError: No module named 'pygame'" ๐
So since pip sees it, it means IDE uses different python)
You should find "Interpreter settings" in your IDE and see what it points to.
If it says "venv", it means your IDE made a virtual environment for you - but had problems to automatically activate it for you (happens on Windows, you need to run a special command once to fix it), and that's why terminal uses wrong pip.
okay i'm new to python
Exception has occurred: ModuleNotFoundError
No module named 'pygame'
File "C:\Users\szymo\Documents\KURS z Phyton\Lekcja12\Gra.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
it fixed!!!
oh
it not :(
i'm using visual code studio
now i have: Exception has occurred: ModuleNotFoundError
No module named 'pygame'
File "C:\Users\szymo\Documents\KURS z Phyton\Lekcja12\Gra.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
do you have 'import pygame' in your code?
yes
try pip install pygame again
i made it in courses
Hey @fiery geode!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
do it like that
yeah the code seems normal
can you send what you are doing in your terminal
import pygame
pygame.init()
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
screen_surface = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Pierwsza gra")
clock = pygame.time.Clock()
game_status = True
def load_image(img_path: str, position):
image = pygame.image.load(img_path)
surface = image.convert()
transparent_color = (0, 0, 0)
surface.set_colorkey(transparent_color)
rect = surface.get_rect(center=position)
return [image, surface, rect]
player_pos = [SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2]
player = load_image('player.png', player_pos)
while game_status:
events = pygame.event.get()
for event in events:
print(event)
if event.type == pygame.QUIT:
game_status = False
pygame.display.update()
clock.tick(60)
pygame.quit()
quit()
sorry i have it in polish
how do u run your code?
my teacher don't know how to fix it
i do it
ok then uninstall pip and install pip again
How do I uninstall Python pip itself?
How to Globally Uninstall Python Packages
Open a command window by entering 'cmd' in the Search Box of the Task bar.
Press Ctrl+Shift+Enter to gain Administration (Admin) privileges.
pip uninstall <packagename>
try that
but how do i install it
oh
Run python get-pip.py . [2] This will install or upgrade pip. Additionally, it will install Setuptools and wheel if they're not installed already. Be cautious if you're using a Python install that's managed by your operating system or another package manager
idk how to do that
can u run py -0 in your terminal and check if there is more than 1 python version installed
have u switched to 3.13 yet? try running it again
its fixed, now its just a problem with your code
okay
i think you are in the wrong working directory
but how do i install pip
okay
type cd Leckja12 in your terminal
py -m ensurepip --upgrade should work
and then re-run your code
The names so cursed ๐
i dont have expertise in pygame, someone else gotta help u with that one haha
okay no problem
i have lesson in next week and we are going to make graphics display i think
thanks for helping
huge thanks
What do you expect to be showing?
i think you arent drawing anything onto the screen
Is there any output when you run it?
add
screen_surface.blit(player[1], player[2])
before the pygame.display.update() line
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.