Trying to import pygame into Spyder

1,330 views
Skip to first unread message

thomas ermel

unread,
Feb 18, 2017, 9:18:41 PM2/18/17
to spyder
Hi there

I'm a beginner, I tried to install pygame on spyder but it doesn't work.
With python it works, but it doesn't with spyder...

When I code this :

import pygame

from pygame.locals import *


pygame.init()


fenetre = pygame.display.set_mode((640, 480))



The answer of spyder is :

runfile('C:/Users/utilisateur/Documents/WinPython/WinPython-64bit-3.4.3.3/settings/.spyder2-py3/sanstitre2.py', wdir='C:/Users/utilisateur/Documents/WinPython/WinPython-64bit-3.4.3.3/settings/.spyder2-py3')
Traceback (most recent call last):

  File "<ipython-input-5-e9501e8c2683>", line 1, in <module>
    runfile('C:/Users/utilisateur/Documents/WinPython/WinPython-64bit-3.4.3.3/settings/.spyder2-py3/sanstitre2.py', wdir='C:/Users/utilisateur/Documents/WinPython/WinPython-64bit-3.4.3.3/settings/.spyder2-py3')

  File "C:\Users\utilisateur\Documents\WinPython\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 682, in runfile
    execfile(filename, namespace)

  File "C:\Users\utilisateur\Documents\WinPython\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 85, in execfile
    exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)

  File "C:/Users/utilisateur/Documents/WinPython/WinPython-64bit-3.4.3.3/settings/.spyder2-py3/sanstitre2.py", line 6, in <module>
    pygame.init()

AttributeError: 'module' object has no attribute 'init'

Please, help me to fix this,


Big Stone

unread,
Feb 19, 2017, 6:13:09 AM2/19/17
to spyder
maybe try:
- get latest pygame-1.9.3
- download the simplest example  aacircle.py (at https://bitbucket.org/pygame/pygame/src look in examples)

- configure spyder to execute in a dedicated window (Execute->Configure->Execute in a dedicated window)

... and voilà, a beautifull circle appears on WinPython-64bit-3.4.4.6Qt5, and so most probably in WinPython-64bit-3.4.3.3
Reply all
Reply to author
Forward
0 new messages