2012-03-02 48 views
8

Tôi đang sử dụng Ubuntu 11.10. Khi nhập khẩu tkinter tôi nhận được những lỗi sau, mặc dù có vẻ như tôi đã cài đặt python-tk bằng cách nào đó. Hãy giúp tôi.Lỗi nhập khẩu Python 3.x tkinter

[email protected]:~$ python3.2 
Python 3.2.2 (default, Sep 5 2011, 22:09:30) 
[GCC 4.6.1] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 

>>> from tkinter import * 

Traceback (most recent call last): 
    File "/usr/lib/python3.2/tkinter/__init__.py", line 40, in <module> 
    import _tkinter 
ImportError: No module named _tkinter 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/lib/python3.2/tkinter/__init__.py", line 42, in <module> 
    raise ImportError(str(msg) + ', please install the python-tk package') 
ImportError: No module named _tkinter, please install the python-tk package 
>>> 
[2]+ Stopped     python3.2 
[email protected]:~$ sudo apt-get install python-tk 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
python-tk is already the newest version. 
The following packages were automatically installed and are no longer required: 
    gir1.2-folks-0.6 gir1.2-polkit-1.0 mutter-common libcaribou0 gir1.2-gkbd-3.0 
    caribou libmutter0 gir1.2-mutter-3.0 gjs gir1.2-caribou-1.0 
    gir1.2-telepathylogger-0.2 cups-pk-helper gir1.2-upowerglib-1.0 
    gir1.2-telepathyglib-0.12 gir1.2-gee-1.0 
Use 'apt-get autoremove' to remove them. 
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded. 

Trả lời

10

Thông báo lỗi là sai. Thay vào đó, hãy cài đặt python3-tk.

+0

Rất cám ơn nhiều người. Nó đang làm việc bây giờ :) – Dewsworld