0

Just started playing with pygame and when creating a new projetc in Pycharm, i'm not able to import pygame. From what i've read i have pygame intalled correctly (running Powershell in the pygame project folder PS C:\Users\54294\PycharmProjects\pygame> pip install pygame==2.1.2

Requirement already satisfied: pygame==2.1.2 in c:\users\54294\appdata\local\programs\python\python311\lib\site-packages (2.1.2))

Now, whenever i want to "import pygame" inside the main.py file, it says

Traceback (most recent call last):

File "C:\Users\54294\PycharmProjects\pygame\main.py", line 1, in

import pygame

ModuleNotFoundError: No module named 'pygame'.

Got it to work once, but refactored the folder and it stopped working.

I've tried:

-running the import pygame and installing the package

-going to File>settings>Python Interpreter and installing the pakage (specifyinhand not specifying version)

-installing pygame as pygame and pygame==2.1.2 from Powershell inside venv\Scripts

Nothing seems to work...

Pygame works fine in the Pythin IDE that comes form isntalling Python (

import pygame

pygame 2.1.2 (SDL 2.0.18, Python 3.11.0)

Hello from the pygame community. https://www.pygame.org/contribute.html).

I'd Apreciate any help

I've tried:

-running the import pygame and installing the package

-going to File>settings>Python Interpreter and installing the pakage (specifyinhand not specifying version)

-installing pygame as pygame and pygame==2.1.2 from Powershell inside venv\Scripts

Nothing seems to work...

IvnMzk
  • 23
  • 5

1 Answers1

0

It seems that your Python interpreter settings might be set incorrectly.

Please check your paths under File > Settings > Project > Python interpreter. Based on your log, it should be set to: c:\users\54294\appdata\local\programs\python\Scripts\python.exe

Here, you can also check the installed packages of this Python interpreter.

Finally, you can also install packages via pip through the Pycharm terminal (on the bottom of your screen). You can try to run your pip-command there as well.

Stefan
  • 36
  • 5
  • Just watched a video from Tim about this and changed what you are saying, tried both python.exe and pythonw.exe but none worked... Also, pygame package isn't installed. When i try to install it, it throws an error. – IvnMzk Nov 07 '22 at 16:10