Reputation: 73
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?
Upvotes: 7
Views: 9400
Reputation: 8
type this in shell: py -m pip install -U pygame --user user is your cmd user.
Upvotes: 0
Reputation: 1
You can either use cmd to install pygame type this pip install pygame (you have to make sure that python is installed) If this doesn't help Use thonny idle I use it because python doesn't work with my pc basically Thonny is a python idle which runs without the requirement of python to be installed and you can also install modules using thonny and type python code as well but make sure that if you import a module in thonny that module can be only used in thonny and can't be used in any other idle unless you install it in cmd but you don't need it as thonny idle is great so if you want to install modules like pygame in thonny 1) Open thonny 2) click on tools 3) click on open shell There you can type pip install pygame and install it successfully I have a potato pc which can't run python because it requires service pack 1 windows7 or above I don't have it I only have windows 7 so I use thonny and use pygame using thonny only. :D
Upvotes: 0
Reputation:
Did you install pygame? You need to type pip install pygame
or sudo install pygame
into terminal. If you are using windows 10, press the windows logo key then type terminal. You can check it's installed with: pygame -H
or pygame help
Upvotes: 0
Reputation: 361
Edit - pygame only works in python >= 3.6.*
If you are using Windows i had the same problem and i know how to fix it, follow the steps:
r
%appdata%
and press enterThis will open the appdata roming file
Look at the bit at the top that says Appdata > roaming
and click on
app data
python36
then go
to scriptsPls comment if this doesnt make sense or you would like further details
Upvotes: 0
Reputation: 33
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.
Upvotes: 2
Reputation: 73
ans done if any one need help delete all python version from system and install python 3.5.2 from https://www.python.org/downloads/release/python-352/
then go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
and search pygame and download pygame‑1.9.3‑cp35‑cp35m‑win_amd64.whl
then go to C:\Users\"your username"\AppData\Local\Programs\Python\Python35\Scripts> in this location in cmd ( command prompt )
type this line and done " pip3 install pygame-1.9.3-cp35-cp35m-win_amd64.whl "
hope this help you
Upvotes: 0