Python Forum

Full Version: TurtleWorld on MAC in Python 3.6 issues
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have an issue getting TurtleWorld to work for my book "ThinkPython" for version 3.6. I cannot get it to work in pycharm or on my terminal CLI. These are my errors:

cha-105889-l:swampy-2.1.7 username$ pip3 install swampy
Requirement already satisfied: swampy in /usr/local/lib/python3.6/site-packages (2.1.7)

cha-105889-l:swampy-2.1.7 username$ python3
Python 3.6.4 (default, Mar 22 2018, 14:05:57)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import tkinter
>>> import swampy.TurtleWorld
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/blamb/Downloads/swampy-2.1.7/swampy/TurtleWorld.py", line 8, in <module>
from Tkinter import TOP, BOTTOM, LEFT, RIGHT, END, LAST, NONE, SUNKEN
ModuleNotFoundError: No module named 'Tkinter'
>>>
>>>
>>> import swampy
>>>
>>>
>>> from TurtleWorld import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'TurtleWorld'
>>>
>>>

This is the code from pycharm:

/Users/blamb/PycharmProjects/ThinkPython/venv/bin/python /Users/blamb/PycharmProjects/ThinkPython/Turtle.py
Traceback (most recent call last):
File "/Users/blamb/PycharmProjects/ThinkPython/Turtle.py", line 1, in <module>
from TurtleWorld import *
ModuleNotFoundError: No module named 'TurtleWorld'

Process finished with exit code 1
The package you're loading is for Python 2.7 and you are running it in 3.6. The name of the package changed from Tkinter to tkinter in 3.x.

You either need to run it in 2.7 or get an updated version of it.
I may have both being used, but can successfully run the following from the newer tkinter version from my 3.6 python version:

import tkinter

tkinter._test()


I cannot run the rest of the code though. This is the code and the error:

import tkinter

tkinter._test()

from TurtleWorld import *

world = TurtleWorld()
bob = Turtle()

def square(t):
    for i in range(4):
        fd(t, 100)
        lt(t)

square(bob)
wait_for_user()
Error:
/Users/username/PycharmProjects/ThinkPython/venv/bin/python /Users/username/PycharmProjects/ThinkPython/Turtle.py Traceback (most recent call last): File "/Users/username/PycharmProjects/ThinkPython/Turtle.py", line 5, in <module> from TurtleWorld import * ModuleNotFoundError: No module named 'TurtleWorld' Process finished with exit code 1
Just before my above error, the tkinter screen did pop up as before, but the TurtleWorld is where it failed. I will try installing it again for the 4th time

The above was from pycharm, this below is from the Terminal:

>>> import _tkinter
>>> import tkinter
>>> import swampy.TurtleWorld
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/swampy/TurtleWorld.py", line 8, in <module>
    from Tkinter import TOP, BOTTOM, LEFT, RIGHT, END, LAST, NONE, SUNKEN
ModuleNotFoundError: No module named 'Tkinter'
The above shows the newer version of tkinter being imported, but the TurtleWorld error points to the older version for python 2.7 with the uppercase "T".
It's the same error in a different place. All of the Tkinter imports need to match, and you need to use the appropriate version of Python for the import you have.