3

i am learning and trying to make a snake game in Python3 i am importing turtle

i am using: Linux mint 19, PyCharm, python37, python3-tk

Traceback (most recent call last):
  File "/home/buszter/PycharmProjects/untitled1/snake.py", line 2, in <module>
    import turtle
ModuleNotFoundError: No module named 'turtle'

everywhere i am reading turtle should be preinstalled, but i still dont have it :(

i tried pip install turtle and says

 pip install turtle
Collecting turtle
  Using cached https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-kvf9on0y/turtle/setup.py", line 40
        except ValueError, ve:
                         ^
    SyntaxError: invalid syntax

    -------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-kvf9on0y/turtle/

EDIT

screenshot of settings of the project in pycharm

screenshot of settings of the project in pycharm

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
buszter
  • 39
  • 1
  • 1
  • 3
  • Does this answer your question? [Why does tkinter (or turtle) seem to be missing or broken? Shouldn't it be part of the standard library?](https://stackoverflow.com/questions/76105218/why-does-tkinter-or-turtle-seem-to-be-missing-or-broken-shouldnt-it-be-part) – Karl Knechtel Apr 25 '23 at 20:58

5 Answers5

1

I know that it's kinda old topic, but I had the same problem right now on my Fedora 31. Reinstalling packages didn't work.
What worked was installing IDLE programming tool (that's just Python IDE for kids), which installs also tkinter module.
I think that installing just python3-tkinter (that's how this package is named in Fedora repo) package would work as well, because turtle is inside Tk module.

Garbulix
  • 11
  • 1
  • The name of the package can also be `python38-tkinter` or `python39-tkinter` depending on your Python version and distribution. – scrutari Oct 02 '21 at 08:39
1

You can't install turtle library via pip, it must be in the standart library. pip install turtle installs this 3rd party library. You can look at download file (this tar.gz file) link of above library and link in the output of pip. They are same.

For the solution, I think you can just copy this and write in a file.

Ekrem Dinçel
  • 1,053
  • 6
  • 17
0

Most probably the python your Pycharm is using is not Python3.7. Try opening a Python prompt and running import turtle, because it should be packaged into python already.

(https://docs.python.org/3/library/turtle.html)

Devesh Kumar Singh
  • 20,259
  • 5
  • 21
  • 40
  • in terminal I've run python3 and import turtle and it is working ... so I've turtle :) , but still not working. I've add a screenshot to the question too :) – buszter Mar 24 '19 at 19:48
  • Then make sure the python you are using there is the same as what you use in PyCharm – Devesh Kumar Singh Mar 25 '19 at 03:10
  • Usually `turtle` module comes with `python`. I say reinstall it. –  Mar 27 '19 at 03:40
0

The screenshot of your settings shows no PythonTurtle package. Simply click on + and find the package named "PythonTurtle" click install package.

Nick
  • 41
  • 1
  • 6
0

An error will pop-up if the installed Python version doesn't include tkinter. Try running sudo dnf install python3-tkinter in the terminal (the command varies according to the OS)

https://youtrack.jetbrains.com/issue/PY-47648