# Why do i have t use tkinter?

#1

“”"
Name: Ang Li, Jash Rathod
Lab: Draw a Fibonacci Spiral
Date: Feb 22, 2018
Class: CS 111

This programe helps us draw the fibonacci spiral based on the input of number of layers from the user.
“”"
import turtle
tortoise=turtle.Turtle()
def fib(n):
“”"
This function is to calculate the Fibonacci sequence.
Parameters:
n: is the numbers that will be in the Fibonacci sequence
Return values:
The return values will be b who is the number is the Fibonacci sequence
“”"
a=0
b=1
for i in range(2,n+1):
a = a + b
a,b = b,a
return b #Returns the fibonacci vaue
def ss(n): #Drawing the squares and spirals
“”"
This function is to draw a square whose sides is the number inside Fibonacci sequence and
the arcs which will form the spiral.
Parameters:
n: is the number that will be the side of the squares and the radius of the arc in the
fibonacci sequence.
Tortoise: is the turtle who will draw the square.
Return Value:
None
“”"
for segment in range(4): #Loop index is defined as 4 for loop function for square
tortoise.forward(fib(n)*5)
tortoise.left(90)
tortoise.pencolor(‘blue’)
tortoise.pensize(3)
tortoise.circle(fib(n)*5,90)
tortoise.pencolor(‘red’)
tortoise.pensize(1)
def main():
“”"
This is the main function to draw the Fibonacci spiral as it calls the other fucntions that calculates the fibonacci sequence and drawas the squares and arcs based on the calculations
“”"
tortoise.hideturtle()
tortoise.speed(10)
n=int(input('How many layers: ')) #Asks user to input the number of layers
for i in range(n+1): #Loop index is defined as n+1 for loop function
ss(i)
screen=tortoise.getscreen()
screen.exitonclick()
main()

ImportErrorTraceback (most recent call last)
in ()
7 This programe helps us draw the fibonacci spiral based on the input of number of layers from the user.
8 “”"
----> 9 import turtle
10 tortoise=turtle.Turtle()
11 def fib(n):

/usr/lib/python2.7/lib-tk/turtle.py in ()
105 #print _ver
106
–> 107 import Tkinter as TK
108 import types
109 import math

/usr/lib/python2.7/lib-tk/Tkinter.py in ()
40 import _tkinter
41 except ImportError, msg:
—> 42 raise ImportError, str(msg) + ‘, please install the python-tk package’
43 tkinter = _tkinter # b/w compat for export
44 TclError = _tkinter.TclError

ImportError: No module named _tkinter, please install the python-tk package

#2

Hi Ang, these are forums for questions about Atom and Electron.

#3

Hey Aerijo , my code is working fine with IDLE , however when I try running it in atom using hydrogen. It gives me the error.

#4

What happens when you run the code with `script`?

#5

Because `turtle.py` imports it, as the stack trace you posted says.

The IPython interpreter is separate from IDLE’s interpreter on your computer. Without looking, I’m 100% positive that they have different packages installed, but I don’t know how to install new packages for Jupyter.