Beginning programmer here. From How to Think Like a Computer scientist I got the following code:
#!/usr/bin/env python3
import turtle
wn = turtle.Screen()
alex = turtle.Screen()
alex.forward(150)
alex.left(90)
alex.forward(150)
The program seems simple enough, Yet I get the following error:
ImportError: No module named turtle
After some internet research, I read that the turtle module can me found within the tkinter package. And so because I have two different python installations, Python 2.7.3 and Python 3.2.3
I ran the following commands in Ubuntu terminal, in hopes to install the missing python modules:
sudo apt-get install python-tk
sudo apt-get install python3.2-tk
It got me nowhere. So how can I install the missing modules for both versions of python?
Thanks!
On ubuntu 16.04,
sudo apt-get install python3-tk
solved my problem, if this not work for you, see this question too Tkinter module not found on Ubuntu
To setup Tkinter module in Python 2:
sudo apt-get install python-tk
in the terminal.import Tkinter
in your program.For Python 3:
sudo apt-get install python3-tk
in the terminal.import tkinter
in your program.Although Tkinter usually comes bundled up with Python 3, the above procedure will work incase the module is not installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With