Python Forum
[PyGame] Error setting up pygame - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: [PyGame] Error setting up pygame (/thread-10906.html)

Pages: 1 2


Error setting up pygame - wazee - Jun-12-2018

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.


RE: Error setting up pygame - metulburr - Jun-12-2018

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


RE: Error setting up pygame - wazee - Jun-13-2018

(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?


RE: Error setting up pygame - ljmetzger - Jun-13-2018

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


RE: Error setting up pygame - wazee - Jun-13-2018

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?


RE: Error setting up pygame - metulburr - Jun-13-2018

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.


RE: Error setting up pygame - ljmetzger - Jun-13-2018

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


RE: Error setting up pygame - wazee - Jun-14-2018

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


RE: Error setting up pygame - metulburr - Jun-14-2018

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-Install-and-Troubleshooting

IF you persist on using 3.7 i would just ask the pygame devs here
https://github.com/pygame/pygame/issues


RE: Error setting up pygame - ljmetzger - Jun-14-2018

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