0
votes

I am a beginning python enthusiast, self-teaching myself from the book of John Zell. I reached the point where I need to learn about objects and about graphics. So, I followed instructions and saved graphics.py into /usr/lib/python3/dist-packages

However, I got his:

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

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/graphics.py", line 151, in import tkinter as tk File "/usr/lib/python3.2/tkinter/init.py", line 42, in raise ImportError(str(msg) + ', please install the python-tk package') ImportError: No module named _tkinter, please install the python-tk package

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3/dist-packages/graphics.py", line 153, in import Tkinter as tk ImportError: No module named Tkinter

I checked and it seems that tkinter is installed. Please kindly help me to go around it, because I dont know what to do next.

Thank you so much!

1
That script is written for Python 2. Python 2 scripts usually aren't compatible with Python 3, so you'll need to install Python 2. - Blender

1 Answers

1
votes

You problem: usr/lib/python3/dist-packages/graphics.py

line 153, in import Tkinter as tk 

In Python 3+, Tkinter is imported as tkinter. Simply edit the graphics.py file to import tkinter as tk. Note: As Bender stated, it will probably be easier to continue learning with python 2.*, as you may encounter further issues in the future.