0

I wrote a script that creates 50 boxes of random color. The script works normally, but once I used py2exe to make it an executable file, it stopped working. The executable worked at first, but then later it stopped working. I started getting this error:

ImportError: No module named turtle

Here is my python code:

import turtle
from random import randint
colors = ['red', 'green', 'yellow', 'purple', 'blue', 'orange', 'black', 'lightgreen',   'navyblue', 'pink']
window = turtle.Screen()
box = turtle.Turtle()
box.speed(4)
box.penup()
box.setx(-350)
box.sety(200)
box.pendown()
for num in range(100):
    box.color(colors[randint(0, 9)])
    for x in range(4):
        box.forward(30)
        box.left(90)
    x = box.xcor()
    if x >= 350:
        y = box.ycor() - 60
        x = box.xcor() - 700
    else:
        y = box.ycor()
        x = box.xcor() + 45

    box.goto(x, y)

I really am not sure why it started giving me this error.

My .exe file is to long to post here, and it is incomprehensible to me anyway. I have python 27's tkinter, so I don't think that's the problem.

Thanks

electron1
  • 97
  • 1
  • 1
  • 10
  • Is that the exact error message? The capitalization looks off. – Winston Ewert Jul 17 '14 at 01:15
  • I changed the capitalization of the error message. – electron1 Jul 17 '14 at 19:23
  • If it worked before, but doesn't now, you must've changed something in setup.py, or added a new dependency. Try deleting your build directories and recompiling, post the output of `python setup.py py2exe`, and the contents of your setup.py. – g.d.d.c Jul 17 '14 at 19:37

1 Answers1

0

Py2exe might not handle some of the dependencies out of the box. Check this advice from the py2exe tutorial:

Dealing With ImportError

ojy
  • 2,402
  • 2
  • 18
  • 23