Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

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.
Quote
#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
Quote
#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?
Quote
#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.whl

Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Quote
#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?
Quote
#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.
Quote
#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
metulburr likes this post
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Quote
#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
Quote
#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
Quote
#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
metulburr likes this post
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [PyGame] Problem importing pygame / installing pygame Klar 4 764 Dec-16-2017, 05:48 PM
Last Post: Klar
  [pyGame] My First Test, Error Fount ! JamieVanCadsand 3 647 Sep-25-2017, 04:13 PM
Last Post: metulburr
  Pygame: Help With JackRouter Error arrangereality 4 970 Aug-02-2017, 03:28 AM
Last Post: arrangereality
  [Pygame] Avoid SentDex pygame tutorials georgecoopers 1 959 Apr-09-2017, 12:40 PM
Last Post: metulburr
  [split] permission error on pygame install pyteach 7 1,879 Jan-23-2017, 11:00 PM
Last Post: pyteach

Forum Jump:


Users browsing this thread: 1 Guest(s)