0

I am new to programming and wanted to use turtle in PyCharm (Community Edition 2020.3). I am running Pop-OS 20.10.

This is what I entered:

import turtle
s = turtle.getscreen()

This is what I got from PyCharm:

Traceback (most recent call last):
    File "/home/przvl/PycharmProjects/Introduction/Turtle Car.py", line 3, in <module>
      import turtle
ModuleNotFoundError: No module named 'turtle'

I installed tkinter with:

sudo apt install python3-tk

I can run turtle from the CLI:

turtle running in CLI

PyCharm is set to the correct Python interpreter (as far as I know):

PyCharm Interpreter settings

flaxel
  • 4,173
  • 4
  • 17
  • 30
przvl
  • 1
  • 2
  • As seen in the last screenshot, the Pycharm project is using a virtual environment. Fixing the base Python installation (`sudo apt install python3-tk`) will not necessarily update virtual environments, because they may have their own copies of files instead of completely symlinking the base Python. In this case, it is necessary to re-create the virtual environment. – Karl Knechtel Apr 25 '23 at 21:01

2 Answers2

0

Your interpreter settings show you did not installed turtle in the virtual environment that Pycharm is configured to work with.

Two options:

  1. Recommended - install `turtle' on the venv (u can just "+" in the pycharm)
  2. Configure Pycharm to work with your system python to where you have probably installed turtle.
Lior Cohen
  • 5,570
  • 2
  • 14
  • 30
  • I can't add turtle manually to the venv. Clicking the "+" for adding packages and searching for "turtle" only gives another, completely unrelated package of the same name ("HTTP Proxy to throttle connections..."). Using command "type -a python3.8" gave two directories "python3.8 is /usr/bin/python3.8" and "/bin/python3.8". I tried setting both in PyCharm and still get the same error. – przvl Dec 11 '20 at 16:48
0

I ended up downloading PyCharm from jetbrains.com and manually installing it via the CLI. The interpreter now works correctly and I can use turtle.

Previously, I used Pop-OS inbuilt Shop and flatpak installation of the program, which seems to cause trouble for some users.

przvl
  • 1
  • 2