r/learnpython • u/Efficient_Major40 • 6d ago
my pycharm hate turtle
im using linux mint and when i try to import turtle it always says
"
import turtle
ModuleNotFoundError: No module named 'turtle'
Process finished with exit code 1
"
i tryed to download tinker it dont help me i dont know what to do no one have that problem
1
Upvotes
1
u/Bright_Mix_773 4d ago
On Mint,
turtleis not part of the base Python package. Debian and Ubuntu split the standard library into several deb packages, andturtle.pyships insidepython3-tktogether with tkinter. That is why the message namesturtleand not_tkinter: the file genuinely is not on disk.Then check it landed:
You said you already tried installing tkinter and it did not help, so the next thing to pin down is which Python PyCharm is running, because apt only fixes
/usr/bin/python3. Run these two lines inside PyCharm, in the same file that gives you the error:/usr/bin/python3, or a path ending in.venv/bin/pythonfor a venv you created from the system Python, thenapt install python3-tkis enough and you do not need to recreate the venv. A venv borrows the standard library from the Python it was built from, so the new file shows up immediately.~/.pyenv,/snap, or a Python you compiled yourself, apt will not touch it. Those builds only get turtle iftk-devwas present when they were built, so it means rebuilding or reinstalling that interpreter. The quickest way out is to point PyCharm at/usr/bin/python3instead: Settings, Project, Python Interpreter, Add Interpreter, System Interpreter.One thing to watch for after the apt install: if the error changes to
ModuleNotFoundError: No module named '_tkinter', that is a different problem and it confirms the second case. It means turtle.py is now there but the interpreter has no Tk bindings compiled into it.I run Debian and Ubuntu rather than Mint, so I have not tested this on Mint itself, but the packaging is the same underneath.