This is my situation:
I tried importing pygame
in both python 3.4.2 and python 3.6.3 using both pip
and pip3
respectively.
In the python 3.4.2 shell:
Traceback (most recent call last) is:
File "", line 1, in
import pygame
ImportError: No module named 'pygame'
In the python 3.6.3 shell:
Traceback (most recent call last):
File "", line 1, in
import pygame
File "C:\Users\aditya dand\AppData\Local\Programs\Python\Python36\lib\site-packages\pygame__init__.py", line 141, in from pygame.base import *
ModuleNotFoundError: No module named 'pygame.base'
Those are the errors that occurred.
I also used pygame-1.9.2a0-hg_5974ff8dae3c%2B.win32-py3.4.msi
.
It's showing the header's file of pygame
, but it's not importing something.
What can I do to solve this?
The Python "ModuleNotFoundError: No module named 'pygame'" occurs when we forget to install the pygame module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install pygame command.
Step1:
check http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame to find a Windows installer that matches the version of Python you're running. The current version of pygame is : pygame-1.9.4-cp37-cp37m-win_amd64.whl
Move this file to the folder C:\Users\username\AppData\Local\Programs\Python\Python37\Scripts
=========================================
Step2:
open cmd
and then type:
cd\
cd /d C:\Windows
cd /d C:\Users\username\AppData\Local\Programs\Python\Python37\Scripts
and then type the command:
pip install pygame
Now you have successfully installed pygame package.
=========================================
Step3:
open PyCharm File >> setting make sure the "Project Interpreter" has the "pygame" package like the following:
File>>Setting>> make sure the "pygame" package is there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With