Tôi đã thực hiện một số nghiên cứu trước về lỗi này. Có một số giải thích ở đây trong StackOverflow có liên quan, các giải pháp được đề xuất là khá không liên quan mặc dù.AttributeError: đối tượng 'module' không có thuộc tính 'maketrans'
Khi tôi cố gắng nhập Gtk từ gi.repository, nó bị treo với kết quả như sau:
bash-4.2$ python3 Python 3.2 (r32:88445, Feb 21 2011, 21:11:06) [GCC 4.6.0 20110212 (Red Hat 4.6.0-0.7)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.2/site-packages/gi/importer.py", line 76, in load_module
dynamic_module._load()
File "/usr/lib64/python3.2/site-packages/gi/module.py", line 251, in _load
overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
File "/usr/lib64/python3.2/site-packages/gi/overrides/Gtk.py", line 400, in <module>
class MessageDialog(Gtk.MessageDialog, Dialog):
File "/usr/lib64/python3.2/site-packages/gi/overrides/Gtk.py", line 404, in
MessageDialog
type=Gtk.MessageType.INFO,
File "/usr/lib64/python3.2/site-packages/gi/module.py", line 127, in __getattr__
ascii_upper_trans = string.maketrans(
AttributeError: 'module' object has no attribute 'maketrans'
Do đây là một nhập khẩu trực tiếp từ python console và không bằng cách thực hiện một kịch bản file python Tôi don thậm chí không có một đầu mối làm thế nào để xử lý này.
có vẻ như nhập khẩu của một mô-đun python 2 với python 3 là 'string.maketrans' vắng mặt trong python 3 –