安装错误Pygame

时间:2013-10-15 06:51:40

标签: python ubuntu pygame

我安装了Python 2.7和Python 3的Ubuntu 12.04。我通过sudo apt-get python-pygame和源代码安装了pygame。当我在Python上尝试>>>import pygame时出现此错误:

`

>>> import pygame<br>
Jello, world!<br>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/pygame/__init__.py", line 255, in <module>
    try: import pygame.surfarray
  File "/usr/lib/python2.7/dist-packages/pygame/surfarray.py", line 69, in <module>
    import pygame._numpysurfarray as numpysf
  File "/usr/lib/python2.7/dist-packages/pygame/_numpysurfarray.py", line 48, in <module>
    import numpy
  File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
    import polynomial
  File "/usr/lib/python2.7/dist-packages/numpy/polynomial/__init__.py", line 18, in <module>
    from polynomial import Polynomial
  File "/usr/lib/python2.7/dist-packages/numpy/polynomial/polynomial.py", line 60, in <module>
    from polytemplate import polytemplate
  File "/usr/lib/python2.7/dist-packages/numpy/polynomial/polytemplate.py", line 20, in <module>
    polytemplate = string.Template('''
AttributeError: 'module' object has no attribute 'Template'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
    from apport.report import Report
  File "/usr/lib/python2.7/dist-packages/apport/report.py", line 18, in <module>
    import problem_report
  File "/usr/lib/python2.7/dist-packages/problem_report.py", line 16, in <module>
    from email.mime.multipart import MIMEMultipart
  File "/usr/lib/python2.7/email/mime/multipart.py", line 9, in <module>
    from email.mime.base import MIMEBase
  File "/usr/lib/python2.7/email/mime/base.py", line 9, in <module>
    from email import message
  File "/usr/lib/python2.7/email/message.py", line 16, in <module>
    import email.charset
  File "/usr/lib/python2.7/email/charset.py", line 14, in <module>
    import email.quoprimime
  File "/usr/lib/python2.7/email/quoprimime.py", line 48, in <module>
    from string import hexdigits
ImportError: cannot import name hexdigits

Original exception was:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/pygame/__init__.py", line 255, in <module>
    try: import pygame.surfarray
  File "/usr/lib/python2.7/dist-packages/pygame/surfarray.py", line 69, in <module>
    import pygame._numpysurfarray as numpysf
  File "/usr/lib/python2.7/dist-packages/pygame/_numpysurfarray.py", line 48, in <module>
    import numpy
  File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
    import polynomial
  File "/usr/lib/python2.7/dist-packages/numpy/polynomial/__init__.py", line 18, in <module>
    from polynomial import Polynomial
  File "/usr/lib/python2.7/dist-packages/numpy/polynomial/polynomial.py", line 60, in <module>
    from polytemplate import polytemplate
  File "/usr/lib/python2.7/dist-packages/numpy/polynomial/polytemplate.py", line 20, in <module>
    polytemplate = string.Template('''
AttributeError: 'module' object has no attribute 'Template'

我看到了Jello World所以我猜它有点工作。我不知道该怎么办。我很感激帮助。提前谢谢。

1 个答案:

答案 0 :(得分:0)

看起来您的盒子上没有安装SDL。

删除你当前的pygame包,然后点击他:

wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz

tar -xzvf SDL-1.2.14.tar.gz

cd SDL-1.2.14

<强> ./配置

make install

一旦完成重新安装pygame,但尝试通过easy_install或pip重新安装:

easy_install pygame

pip install pygame

你应该好好去追寻。