Python Forum

Full Version: Error setting up pygame
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
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
(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?
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
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?
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.
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
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
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
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
Pages: 1 2