#๐Ÿ”’ pygame problem

109 messages ยท Page 1 of 1 (latest)

fiery geode
#

Import "pygame" could not be resolved

neat plinthBOT
#

@fiery geode

Python help channel opened

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.

static sinew
#

Did you pip install pygame?

#

Try to type, "pip install pygame" in your terminal or command prompt and then rerun your code.

fiery geode
#

Requirement already satisfied

static sinew
#

Try, "pip uninstall pygame" and then "pip install pygame"

fiery geode
#

still not working

static sinew
#

The code or the terminal prompt?

#

Does it still say could not be resolved?

golden egret
#

that might fix the issue

fiery geode
#

okay

sudden bison
fiery geode
#

okay

sudden bison
# static sinew The code or the terminal prompt?

("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)

sudden bison
# fiery geode okay

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.

fiery geode
#

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'

fiery geode
#

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'

golden egret
fiery geode
#

yes

golden egret
#

try pip install pygame again

fiery geode
golden egret
#

paste your code

#

maybe something to do with your code

#
hi
fiery geode
#

i made it in courses

neat plinthBOT
#

Hey @fiery geode!

Please edit your message to use a code block

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
golden egret
#

do it like that

#

yeah the code seems normal

#

can you send what you are doing in your terminal

fiery geode
#
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

golden egret
#

how do u run your code?

fiery geode
golden egret
#

do you use code runner or manually in terminal

#

okay yeah idk whats wrong

fiery geode
#

my teacher don't know how to fix it

golden egret
#

can you try like

#

uninstalling pygame

#

then install again

fiery geode
#

i do it

golden egret
#

ok then uninstall pip and install pip again

fiery geode
#

how?

#

i do it

golden egret
# fiery geode how?

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

fiery geode
#

but how do i install it

golden egret
#

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

fiery geode
#

idk how to do that

autumn charm
#

can u run py -0 in your terminal and check if there is more than 1 python version installed

fiery geode
#

but how i install pip

autumn charm
#

if you look at the bottom right of your ide

#

does it says 3.13 or 3.12

fiery geode
#

yes

#

3.12.4

autumn charm
#

click on it and there will be a dialog that pops up

#

change to 3.13

fiery geode
#

3.13.5?

#

but how do install Pip

#

because i removed it

autumn charm
#

have u switched to 3.13 yet? try running it again

fiery geode
#

yes i switched

#

so i fixed it?

autumn charm
#

its fixed, now its just a problem with your code

fiery geode
#

okay

autumn charm
#

i think you are in the wrong working directory

fiery geode
#

but how do i install pip

autumn charm
#

type cd Leckja12 in your terminal

autumn charm
autumn charm
fiery geode
autumn charm
#

whatever your folder name is

fiery geode
#

which folder?

#

oh this

#

Lekcja12

#

sorry i'm polish

fickle vapor
#

The names so cursed ๐Ÿ’€

fiery geode
#

Lekcja means lesson

#

WORKED

#

but things are not showing

autumn charm
#

i dont have expertise in pygame, someone else gotta help u with that one haha

fiery geode
#

okay no problem

#

i have lesson in next week and we are going to make graphics display i think

#

thanks for helping

#

huge thanks

timid pilot
fiery geode
#

graphics

#

it's black

autumn charm
timid pilot
autumn charm
#

add

screen_surface.blit(player[1], player[2])

before the pygame.display.update() line

fiery geode
#

Okay

#

I need to take a break

neat plinthBOT
#
Python help channel closed for inactivity

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.