2

它工作正常,但突然模块“gasp”停止工作并出现此错误:

choose between a, b and c : b
function_b was called...
Traceback (most recent call last):
  File "pitch.py", line 1, in <module>
    from gasp import *
  File "/usr/lib/python2.7/site-packages/gasp/__init__.py", line 15, in <module>
    from api import *
  File "/usr/lib/python2.7/site-packages/gasp/api.py", line 26, in <module>
    import backend
  File "/usr/lib/python2.7/site-packages/gasp/backend.py", line 27, in <module>
    import gobject
  File "/usr/lib/python2.7/site-packages/gobject/__init__.py", line 26, in <module>
    from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "/usr/lib/python2.7/site-packages/glib/option.py", line 33, in <module>
    import optparse
  File "/usr/lib/python2.7/optparse.py", line 77, in <module>
    import textwrap
  File "/usr/lib/python2.7/textwrap.py", line 40, in <module>
    class TextWrapper:
  File "/usr/lib/python2.7/textwrap.py", line 82, in TextWrapper
    whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
AttributeError: 'module' object has no attribute 'maketrans'

请注意,我的程序不会要求在“a、b 和 c”之间进行选择,但这里的控制台仍然会询问,并且在输入选择后会显示错误消息。

例如,使用 gasp 的示例程序是:

from gasp import *

begin_graphics(width = 800, height = 600, title = "A Window", background = color.RED)

Circle((200, 200), 60)
Line((100, 400), (580, 200))
x = Box((400, 350), 120, 100, thickness =1, filled = True)
Circle((10, 400), 2)
Image("/user/Pictures/xyz.jpg", (110, 90), width = 200, height = 160)
move_to(x, (100, 100))
#remove_from_screen(x)

update_when('key_pressed')
end_graphics()

它过去可以正常工作,但现在不能正常工作,每个使用 gasp 模块的程序都是这种情况。

哦,我在 Linux 机器上使用 python 2.7.8。

4

0 回答 0