You are not logged in.

#1 2011-08-28 04:25:31

carebearboy
Member
Registered: 2011-07-03
Posts: 56

Python error: ImportError: No module named pygame

I get this error when attempting to import pygame:


Python 3.2.1 (default, Jul 11 2011, 12:37:47) 
[GCC 4.6.1] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
Traceback (most recent call last):
  File "/home/user/Documents/fun.py", line 3, in <module>
    import pygame, sys, random
ImportError: No module named pygame
>>> 


I've tried installing:

python3-pygame
python3-pygame2
python-pygame
and a couple others...

Either I get the same error or the install yaourt aborts due to a bad compile. I noticed that I have python 2.7 also installed on my computer.

Offline

#2 2011-08-28 06:31:49

doorknob60
Member
Registered: 2008-09-29
Posts: 403

Re: Python error: ImportError: No module named pygame

Well I don't know if this is what you want, but you could use python 2.7 by executing 'python2' instead of 'python', it should work in there, but maybe you're trying to make it work in Python 3 though in which case, I don't know what to say, I haven't used Pygame in Python3 yet, only Python 2.x.

Offline

#3 2011-08-28 15:15:34

carebearboy
Member
Registered: 2011-07-03
Posts: 56

Re: Python error: ImportError: No module named pygame

doorknob60 wrote:

Well I don't know if this is what you want, but you could use python 2.7 by executing 'python2' instead of 'python', it should work in there, but maybe you're trying to make it work in Python 3 though in which case, I don't know what to say, I haven't used Pygame in Python3 yet, only Python 2.x.

Yes, I got it to work in python 2 at least, so I could possibly do that, but I am trying to learn python 3 atm, and the book I am reading (Python 3 for the absolute beginner) refers to Python 3 code only.

I was on #archlinux and many people were saying pygame is not yet ready for python 3 in arch yet. In this case I may need to put another distro on the laptop just to learn it, though I would rather not do that.

Offline

#4 2011-08-28 18:04:18

Nisstyre56
Member
From: Canada
Registered: 2010-03-25
Posts: 85

Re: Python error: ImportError: No module named pygame

Maybe you can put off learning PyGame and just follow the book you have for now?

Python 3 is a good improvement, so you should probably keep on learning it if you've already started.

According to the FAQ, it should work though:

http://pygame.org/wiki/FrequentlyAskedQ … Python%203?

You can try installing it "manually" (not with pacman or an AUR helper)


In Zen they say: If something is boring after two minutes, try it for four. If still boring, try it for eight, sixteen, thirty-two, and so on. Eventually one discovers that it's not boring at all but very interesting.
~ John Cage

Offline

#5 2011-08-28 19:36:13

kachelaqa
Member
Registered: 2010-09-26
Posts: 216

Re: Python error: ImportError: No module named pygame

carebearboy wrote:

I get this error when attempting to import pygame:


Python 3.2.1 (default, Jul 11 2011, 12:37:47) 
[GCC 4.6.1] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
Traceback (most recent call last):
  File "/home/user/Documents/fun.py", line 3, in <module>
    import pygame, sys, random
ImportError: No module named pygame
>>> 

I've tried installing:

python3-pygame
python3-pygame2
python-pygame
and a couple others...

Either I get the same error or the install yaourt aborts due to a bad compile. I noticed that I have python 2.7 also installed on my computer.

Have you tried python3-pygame-svn?

I'm not a pygame user myself, but it built okay for me, and I was able to import it in python3 with no errors.

EDIT: just noticed that the pkgbuild is missing a dependency: python-numpy.

Last edited by kachelaqa (2011-08-28 19:42:06)

Offline

#6 2011-08-29 01:22:30

carebearboy
Member
Registered: 2011-07-03
Posts: 56

Re: Python error: ImportError: No module named pygame

Nisstyre56 wrote:

Maybe you can put off learning PyGame and just follow the book you have for now?

That's what I'll likely have to do.

Have you tried python3-pygame-svn?
I'm not a pygame user myself, but it built okay for me, and I was able to import it in python3 with no errors.
EDIT: just noticed that the pkgbuild is missing a dependency: python-numpy.

I downloaded python-numpy and then tried recompiling and I get this:

chmod: cannot access `/var/abs/local/yaourtbuild/python3-pygame-svn/pkg/usr/include/python3.2mu/pygame/*': No such file or directory

I had managed to get over a previous error complaining about a tmp file missing by renaming python3.2m to python3.2mu but this time that does not work as the directories are created and deleted too fast in the var directory it seems.

Anyways, I'm more then halfway into the book and it's coming along well. smile

Offline

Board footer

Powered by FluxBB