简体   繁体   中英

Trouble importing pygame module using python 3.2.2

I have been trying to get the pygame module to work with python3 in a macbook 10.6. I read it was tricky, I had to install from source code following these instructions: http://programming.itcarlow.ie/PyGameInstall.pdf Everything went OK, but when I try to import pygame I get this error:

Python 3.2.2 (v3.2.2:137e45f15c0b, Sep  3 2011, 17:28:59) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/pygame/__init__.py", line 95, in <module>
    from pygame.base import *
ImportError: dynamic module does not define init function (PyInit_base)

I have no idea what this means. I have done the regular installation and it works fine with python 2.7 but I want some features from python3. Any ideas about what's wrong here?

I found this question because I was faced with the same challenge. I discovered that Python 3.2.x has a bug with pygame package. I wanted Python 3.x with pygame. I uninstalled Python 3.2.3 and reinstalled Python 3.1.4 then installed pygame-1.91.win32-py3.1.msi and it now works for me.

Python 3.x series is not retro-compatible with 2.x series; thus you need the specific pygame version for Python 3.x (or run it through 2_to_3 script, although I'm not sure it works on C code too..). Why don't you want to use Python 2.7?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM