Can't import turtle package for Python


I’ve installed an old laptop with EndlessOS, in order to teach my 9 year old nephew some computer skills, including programming.

Almost all Python study books for kids use the package “turtle” in their example codes. However, it seems that this package was removed from the standard library for the Python installation that comes with EndlessOS.

Alternatively, I’ve tried to get a virtual environment working. But it seems either the IDE doesn’t recognize that the virtual environment exists, or I get turtle installed but it doesn’t show up in the available modules, or turtle is imported but all the functions can be found but not executed…

Willing to add more information in the form of screenshots, but perhaps someone can give me a ballpark solution first. Perhaps I’m looking in the wrong direction altogether…


For this tutorial, i assume that you are using Thonny as the IDE, but it should work for others too if you adjust the package names.

Open Terminal and run:

flatpak run --command=sh org.thonny.Thonny

and then:

mkdir -p /var/data/python/lib/python3.10/site-packages
cd /var/data/python/lib/python3.10/site-packages

The above steps just need to be done once, the Turtle library is now available for the Python installation in question. Fire up Thonny and run a sample code:

(For a aspiring young programmer, i highly recommend Thonny as an IDE :slight_smile: )

Gawsh, you make me feel stupid and thankful in the same post! :smile: But both solutions also didn’t seem to work…

Your suggestion to just place the library file in my project folder is a good patch that serves my purpose. Unfortunately, when placing it in the same folder as my other file it still says it can’t find the turtle library.

  • Do I need to define a project folder first in Thonny?
  • I tried via the Terminal to run my with python3 but that returns the error that it can’t find the tkinter module as well… Is my installation bugged?

Fixing it is of course always preferred. Unfortunately, I didn’t get that working yet… Possibly because I don’t understand flatpaks. I’ve tried to navigate to /var/data/python after the flatpak command but it seems that doesn’t exist. /var/data only contains ‘recently-used.xbel’.

I’m logged in as the childs account. Changing to the administrator account doesn’t seem to work any better.

I tried several IDEs and Thonny seems indeed one of the preferred.

  • Pyzo seemed a bit too complicated
  • Pippy is extremely simplified, but perhaps also a bit too abstract
  • Thonny seems simple, not too much. And the assistent seems very useful.


the first solution you mentioned is obsolete, i posted it first and then thought about a more elegant solution which led to the edit of my post and directly leads to #2

Unfortunately, i just missed a necessary command (mkdir …) - post above has been updated to reflect the correct sequence of commands.

To make things more clear about the whole Flatpak thingie:

  1. Flatpak applications run inside a Sandbox and have very limited abilities to interact with the host system for security reasons - which is great in general!
  2. … but this comes at a price.
  3. The first command i mentioned (flatpak run…) opens a shell inside the sandbox. You’ll see that you are inside the sandbox as the prompt has been prefixed with a little box symbol:
  4. Inside this sandbox we have to create a directory where the python installation of this sandbox is looking for site specific modules. We can get this necessary path with the following command:
    As /app and /usr is read-only inside the sandbox - too for security reasons - only /var remains as the path of choice for our modules.
  5. Now we execute the necessary commands to create the directory in question, change to it and download the turtle module into it. When this has been done, the module stays with this sandbox and the IDE is able to use it.

Got it working! :partying_face:

Some notes:

  • yesterday I was messing around too much in my terminal I think, because the flatpak command didn’t show the box. Today I started a new terminal and this time it did show the box.
  • I tried flatpak list and noticed I can now find all flatpaks installed. So I could change their sandboxes if I wish. But I think I’ll indeed stay with Thonny!
  • Since he’s about 2 hour drive away from me, I’ve also installed AnyDesk and set it up that I can view without accepting.

If you have any more recommendations for a 10 year old on EndlessOS, that will always be appreciated. In any case, thanks a lot for getting it all started for my nephew!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.