I have just started Python recently and for some reason, I cannot import anything on my computer. I can do it on the computer at my school, but not my laptop. This is the message I received when I tried to import the program "cTurtle"

IDLE 2.6.1      
>>> import cTurtle

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import cTurtle
ImportError: No module named cTurtle

Does anyone know what I'm doing wrong?

8 Years
Discussion Span
Last Post by ultimatebuster

Try something simple:

import math

print (math.sqrt(4))

If that works then is it possible you do not have the module cTurtle on your home computer?

Not all modules come with python and thus must be downloaded separately.

If that doesn't work then check to make sure whatever editor your using is pointed to the correct paths to search in for modules.

Edited by Mensa180: n/a


Alright, importing math worked, so that's a good sign. But I do have the cTurtle program on my computer. I have opened it from the file location and from Python to view the code, but it still will not import for me. Is it possible that it needs to be saved in a specific area to be imported?


I found the solution! Apparently, you have to be sure that the program that you want to import is within your "Lib" folder. Otherwise Python will not find the program.

I guess it was a case of looking for programs in all the wrong places. Thanks for giving me an idea of how to get it done.

# show the system path (aka. PYTHONPATH), a list of directories
# that Python by default would look into
# item at index 0 would be the working directory

import sys
print( sys.path )

"""possible output -->

As you can see, you can put the module cTurtle.py into any of these directories, with lib being one of the better choices. Also remember that module names are case sensitive even on a Windows system.

Edited by vegaseat: n/a


You dont necessarily put your cTurtle.py into any of the folders. Make sure python searches the right locations for import :

import sys
import cTurtle

Edited by britanicus: n/a


well the order of search goes from the current directory, to the modules within the current directory, then sys.path

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.