Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Python and pygame

  1. #1
    Join Date
    Jun 2007
    Location
    Costa Rica
    Beans
    117
    Distro
    Ubuntu 10.04 Lucid Lynx

    Python and pygame

    Hi, I need help with python and pygame... I'm supposed to do a chess in python 3.1 and decided to use pygame... I installed it (synaptics) and tried to import it... but when I try to import it I get this error message:

    Code:
    Traceback (most recent call last):
      File "<pyshell#5>", line 1, in <module>
        import pygame
    ImportError: No module named pygame
    I'm using pygame 1.9.1. Anyone know how to import it correctly? or how to install it so that I can use it on python 3.1?

    I'd use python 2.6 but our teacher told us to use 3.1 :/ help me please!!

    Thanks.

  2. #2
    Join Date
    Jun 2010
    Location
    UK
    Beans
    206
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Python and pygame

    The repo package doesn't have the python3 module, I had the same problem. I solved it by compiling pygame from source. I think I downloaded it and untared it, then:

    $ python3 config.py
    $ 2to3 setup.py -w
    $ sudo python3 setup.py

    You'll need to do this to each computer that you'll use your game on unless you put pygame into a local folder. If you have any problems, just post them back here.

  3. #3
    Join Date
    Jun 2007
    Location
    Costa Rica
    Beans
    117
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Python and pygame

    Thanks a lot! ^^ but... everything went fine until i run the last command (sudo python3 setup.py)... here's what i get:

    Code:
    No Arguments Given, Perform Default Install? [Y/n]y
    Skipping module _numericsurfarray for Python 3.1.1+ (r311:74480, Nov  2 2009, 14:49:22) 
    [GCC 4.4.1] build.
    Skipping module _numericsndarray for Python 3.1.1+ (r311:74480, Nov  2 2009, 14:49:22) 
    [GCC 4.4.1] build.
    Skipping module scrap for Python 3.1.1+ (r311:74480, Nov  2 2009, 14:49:22) 
    [GCC 4.4.1] build.
    Skipping module _camera for Python 3.1.1+ (r311:74480, Nov  2 2009, 14:49:22) 
    [GCC 4.4.1] build.
    running install
    running build
    running build_py
    running build_ext
    building 'pygame.imageext' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/SDL -I/usr/include -I/usr/include -I/usr/include/python3.1 -c src/imageext.c -o build/temp.linux-i686-3.1/src/imageext.o
    In file included from src/imageext.c:47:
    src/pygame.h:75:20: error: Python.h: No such file or directory
    In file included from src/imageext.c:47:
    src/pygame.h:122: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘lenfunc’
    src/pygame.h:123: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ssizeargfunc’
    src/pygame.h:124: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ssizeobjargproc’
    src/pygame.h:125: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ssizessizeargfunc’
    src/pygame.h:126: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ssizessizeobjargproc’
    src/pygame.h:127: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘readbufferproc’
    src/pygame.h:128: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘writebufferproc’
    src/pygame.h:129: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘segcountproc’
    src/pygame.h:130: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘charbufferproc’
    src/pygame.h:234: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
    src/pygame.h:275: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
    src/pygame.h:310: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
    src/pygame.h:349: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
    src/pygame.h:387: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
    src/pygame.h:450: error: expected specifier-qualifier-list before ‘PyObject’
    src/pygame.h:457: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
    src/pygame.h:499: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
    src/pygame.h:567: error: expected specifier-qualifier-list before ‘PyObject_HEAD’
    src/imageext.c:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    src/imageext.c: In function ‘opengltosdl’:
    src/imageext.c:506: warning: implicit declaration of function ‘PyErr_SetString’
    src/imageext.c:506: error: ‘PyExc_RuntimeError’ undeclared (first use in this function)
    src/imageext.c:506: error: (Each undeclared identifier is reported only once
    src/imageext.c:506: error: for each function it appears in.)
    src/imageext.c:506: error: ‘PyObject’ undeclared (first use in this function)
    src/imageext.c:506: error: expected expression before ‘)’ token
    src/imageext.c:510: error: expected expression before ‘)’ token
    src/imageext.c:517: error: ‘PyExc_MemoryError’ undeclared (first use in this function)
    src/imageext.c:517: error: expected expression before ‘)’ token
    src/imageext.c:537: error: expected expression before ‘)’ token
    src/imageext.c:537: error: expected expression before ‘)’ token
    src/imageext.c: At top level:
    src/imageext.c:552: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    src/imageext.c:646: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_imageext_methods’
    src/imageext.c:657: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘initimageext’
    error: command 'gcc' failed with exit status 1
    Any idea?

  4. #4
    Join Date
    Jun 2010
    Location
    UK
    Beans
    206
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Python and pygame

    sudo apt-get install python3-dev is the command your looking for.

  5. #5
    Join Date
    Jun 2007
    Location
    Costa Rica
    Beans
    117
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Python and pygame

    Thanks! It works great now

  6. #6
    Join Date
    Dec 2009
    Beans
    25
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Python and pygame

    I have this exact same problem. However, your steps didn't work for me. It seems to have installed correctly, but i still can't get it to import into idle.

  7. #7
    Join Date
    Jun 2007
    Location
    Costa Rica
    Beans
    117
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Python and pygame

    You are not getting any error message?

  8. #8
    Join Date
    Dec 2009
    Beans
    25
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Python and pygame

    Well, it doesn't seem to like it when i use the command python3, so i just used plain python, and it seemed to compile perfectly. It just doesn't show up in idle.

  9. #9
    Join Date
    Jun 2010
    Location
    UK
    Beans
    206
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Python and pygame

    python2 modules don't work in python3 and vice versa. Is Idle for python 2 or 3?

  10. #10
    Join Date
    Jun 2010
    Beans
    11

    Re: Python and pygame

    Thx so much u saved my life!

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •