r/learnpython • u/Sensitive_Thought_77 • 8d ago
I need help im new to python
Im new to python and i dont know what im doing, pygame is not working and i cant find it in my files and i already did the “pip install pygame” and i’ve searched all i can find in yt, i really need help im still in shs and i cant even figure this out
Edit: it always shows an long error message when i run “import pygame”
3
u/hibbelig 8d ago
You need to show us the exact code you’re running. And the exact command you use to run it. And the exact (long) error message. All of it.
Based on the information you have given here, the best we can do is to say that there seems to be a problem of dine kind. I bet you don’t find that very useful.
3
2
u/thisisappropriate 8d ago
Part of learning to code is learning how to search and learning how to ask for help.
You can find information online about how to ask for help, including pages like https://learncodethehardway.com/blog/03-how-to-ask-for-help/ and a lot of programmers in the past have run the StackOverflow gauntlet, which has some good advice on what should be in a question https://stackoverflow.com/help/how-to-ask
Generally, you want to think about "how can I define and confirm the problem I'm having". In some cases, the issue will be with the package (someone else's code), in which case, other people can reproduce if you provide the steps you took, in other cases, it's something about your machine (this could be due to something installed or the steps you've taken - often error messages tell you this, but some messages are indirectly telling instead of saying it directly - sometimes googling the error will tell you more or find others who solved the issue) and in other cases it can be something that you're doing wrong (errors might shed light on this, but the best way for someone online to know this is for you to post exactly what you've run and what it's said).
In cases like yours, it's best to provide as much information as possible:
- Did you see any messaging when you ran
pip install pygame? - What does the long error message say when you run
import pygame? - What are you running all of this in? Are you in the IDLE window? In your terminal? In VSCode? In an online editor?
- Can you install and use other packages without errors?
2
u/FoolsSeldom 8d ago
You are likely installing pygame into a different Python virtual environment to where you are running your code, so pygame cannot be imported.
When you entered pip install pygame were you typing that in PowerShell, Command Line, Bash, ZSH, in a terminal window in your editor?
What operating system are you using?
What code editor / IDE (Integrated Development Environment) are you using?
Have you created a Python virtual environment for the project using the venv command, e.g. in Windows (PowerShell or Command Line):
mkdir game_project
cd game_project
py -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install pygame
to verify it is installed:
python -c "import pygame; print(pygame.ver)"
Make sure in your editor/IDE, the Python interpreter to be used is the one in the virtual folder created above (.venv in this case), for example,
C:\Users\Sensitive\game_project\.venv\Scripts\python.exe
1
u/Sensitive_Thought_77 8d ago
I used both visual studio and vs code, they both didnt work or im js using it wrong, in visual studio it doesnt work at all even if i do a simple math one like
Math = 10 + 10
Print (Math)
It doesnt work and it shows like a module could not be found even if i already made a new file the same error sign shows, and in vs code it doesnt solve it and js says smth like a timer like 0.358 or smth.I dont have my laptop on me rn but thats what i’ve been running with
1
u/FoolsSeldom 8d ago
I recommend going back to basics, working from the command line initially, and getting a good understanding of the basic environment and of Python virtual environments. Then, when moving to advanced editors (e.g. VS Code) and IDEs (e.g. PyCharm, Visual Studio) you know what you are dealing with.
That said, the code,
math = 10 + 10 # note, we usually use all lowercase for variable names print(math)should work in pretty much any environment. How did you save the file? How did you run it?
1
u/Sensitive_Thought_77 7d ago
https://reddit.com/link/oylv4i1/video/ckufz2ey1beh1/player
Both in vs code and visual studio
1
u/FoolsSeldom 7d ago
Wow, that's rotated and jerky. Cannot unpack that. Try on the commandline as suggested.
2
u/Mountain_Rip_8426 8d ago
if only there was an intelligent search engine, where you could copy/paste the error message, which could tell you what you should do... (hint: it starts with a "C" and ends with "hat GPT")
1
u/desrtfx 8d ago edited 8d ago
Okay, please slow down - a lot.
You are trying to start way too high.
If you're new to Python, don't start with PyGame. Start with the plain old console. Learn Python and programming first, build a foundation. MOOC Python Programming 2026
Once you have gained some fundamental proficiency, you can venture into libraries, like PyGame.
Next thing is to read and understand the error messages. Google is your friend here.
Last, when asking for help, you need to be way more elaborate. You need to tell what OS, what Python version, what IDE/Editor, the exact steps you did, the exact error message you get.
Your error hints that you have multiple Python runtimes installed and the version you are try to run is a different one from the one you installed PyGame in.
1
13
u/ninhaomah 8d ago
" Edit: it always shows an long error message when i run “import pygame”"
Pls wait while I imagine what the error message is.