Python Forum
[PyGame] Error setting up pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Error setting up pygame
#1
Hi,
I am new to Python. I got it installed and worked with Netbeans. However I cannot get pygame to work. When I compile I got the following error:

Traceback (most recent call last):
File "C:\src\camera.py", line 5, in <module>
import pygame
File "C:\PythonX\Lib\site-packages\pygame\__init__.py", line 95, in <module>
from pygame.base import *
ImportError: No module named base

I am guessing I may have installed the wrong pygame or what. I have python 3.7 32bit and pygame-1.9.2a0.win32-py2.7. Any help is appreciated.
Reply
#2
Quote:pygame-1.9.2a0.win32-py2.7
the name of the pygame file tells you details about it. Its pygame 1.9.2a0 for windows 32 bit and python 2.7

You need the 3.7 one.

I would get it from here
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

the second to last one entitled
pygame‑1.9.3‑cp37‑cp37m‑win32.whl
Recommended Tutorials:
Reply
#3
(Jun-12-2018, 11:54 PM)metulburr Wrote:
Quote:pygame-1.9.2a0.win32-py2.7
the name of the pygame file tells you details about it. Its pygame 1.9.2a0 for windows 32 bit and python 2.7

You need the 3.7 one.

I would get it from here
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

the second to last one entitled
pygame‑1.9.3‑cp37‑cp37m‑win32.whl

Thanks metulburr. I tried that but I am getting the following. Any idea what I need to do to fix this?
C:\>py -3.7 -m pip install pygame-1.9.3-cp37-cp37m-win32
Collecting pygame-1.9.3-cp37-cp37m-win32
Could not find a version that satisfies the requirement pygame-1.9.3-cp37-cp37m-win32 (from versions: )
No matching distribution found for pygame-1.9.3-cp37-cp37m-win32

Ok I got pygame3.7 installed but when I try to run a module with import pygame I am getting:
Exception in thread "main" File "C:\Users\HongZ\AppData\Local\Programs\Python\Python37-32\Lib\site.py", line 177
file=sys.stderr)
^
SyntaxError: no viable alternative at input '='
Any idea?
Reply
#4
I think you forgot the .whl extension when attempting to install pygame.
Try py -3.7 -m pip install pygame-1.9.3-cp37-cp37m-win32[b].whl[/b]

Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Reply
#5
Thanks Lewis
Yes. I forgot the .whl extension. I got that fixed and I got pygame3.7 installed but when I try to run a module with import pygame I am getting:
Exception in thread "main" File "C:\Users\HongZ\AppData\Local\Programs\Python\Python37-32\Lib\site.py", line 177
file=sys.stderr)
^
SyntaxError: no viable alternative at input '='
Any idea?
Reply
#6
python 3.7 isnt out yet so there could be who knows how many bugs. I would install python 3.6 and the pygame for python 3.6 (its not the same whl file as you have download either) All that whl files states is py36 which it could be python 3.6.5, python 3.6.4, python 3.6.3, etc. I would start with 3.6.5 and go from there.

note you should also just be able to do
pip install pygame
from the specified python version and it will install the proper pygame for that python version making it more easier for noobs.
Recommended Tutorials:
Reply
#7
In the future please post the entire Traceback error in Error Code Tags. In addition post your code inside Python CODE TAGS. If the code is large, edit the code to the minimum amount of code that will reproduce the error.

My speculation is that you are missing a close parentheses ')' on the line before the line mentioned for the Traceback error in your code, not in library file site.py.

Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Reply
#8
I did some stuff and got rid of the other errors and got pygame 3.7 installed but I am back to where I was. I am getting the same tracback. I explored the pygame folder and cannot find a base folder. Is this why I am getting the following message:
Traceback (most recent call last):
File "C:\src\camera.py", line 5, in <module>
import pygame
File "C:\PythonX\Lib\site-packages\pygame\__init__.py", line 95, in <module>
from pygame.base import *
ImportError: No module named base
Thanks
Reply
#9
like i said i would use python 3.6. That is the latest official released version.

Are you positive you are using the 32 bit python? Are you using pip to install the wheel? HAve you read this tutorial?
https://python-forum.io/Thread-PyGame-In...leshooting

IF you persist on using 3.7 i would just ask the pygame devs here
https://github.com/pygame/pygame/issues
Recommended Tutorials:
Reply
#10
I had no problem with the following code using Python 3.6.5 on Windows 10:
import pygame
from pygame.base import *
print("Import ran with no Traceback error.")
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Pygame attribute error djwilson0495 3 3,890 Feb-18-2021, 03:34 PM
Last Post: michael1789
Big Grin Error installing Pygame-Zero dpa2007 1 3,135 Dec-26-2020, 03:50 PM
Last Post: MK_CodingSpace
  pygame error in my clicker game CrazyMakes 2 2,511 Apr-19-2020, 03:04 AM
Last Post: Windspar
  Error to install pygame skp 1 3,454 Apr-14-2020, 05:17 PM
Last Post: joe_momma
  pygame setting borders? thepelican3 2 7,693 Feb-16-2020, 02:37 PM
Last Post: Windspar
  installing pygame error pylab 1 4,183 Dec-31-2019, 05:44 PM
Last Post: pylab
  [PyGame] pygame image loading error BlueClaw 6 6,322 Dec-10-2019, 08:50 PM
Last Post: BlueClaw
  Problem with music - Pygame.error GaseBall 1 3,150 Nov-28-2019, 07:46 PM
Last Post: SheeppOSU
  Pygame to exe error Clunk_Head 0 2,923 Oct-19-2019, 01:34 PM
Last Post: Clunk_Head
  [pyGame] My First Test, Error Fount ! JamieVanCadsand 3 5,245 Sep-25-2017, 04:13 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020