Swampy.turtleworld Not Working In Python 3.4
I m currently learning python using the ThinkPython book, am using python 3.4 and the Anaconda IDE. Part of what I need to continue is to install a module called swampy. I installe
Solution 1:
The book shows these directions if you've downloaded the source code:
from TurtleWorld import *
world = TurtleWorld()
bob = Turtle()
print(bob)
wait_for_user()
If you want to run the code after installing with pip, this should work:
from swampy.TurtleWorld import *
world = TurtleWorld()
bob = Turtle()
print(bob)
wait_for_user()
The reason what you're doing isn't working is because TurtleWorld
is a module within the swampy
package, which contains a functions with the same name, i.e. TurleWorld
. So when you do import swampy
and then try calling swampy.TurtleWorld
you're trying to call a module rather than the function.
Solution 2:
I'm currently studying that book, too. I solved this problem by adding:
import swampy.TurtleWorld
to ensure that the TurtleWorld module in the swampy module runs in your shell. This works as long as your Python version is 3.4 or 3.5.
Post a Comment for "Swampy.turtleworld Not Working In Python 3.4"