jimmytt
jimmytt

Reputation: 254

Can't import turtle on Mac OS Mojave (version 10.14.2)

Trying to simply import turtle to run some lines, but my macOS Mojave (version 10.14.2) can't run it.

Mac @ ~/Desktop - [master] $ python3 SquareSpiral1.py
Traceback (most recent call last):
  File "SquareSpiral1.py", line 2, in <module>
    import turtle
  File "/Users/Mac/Desktop/turtle.py", line 1
    Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
             ^
SyntaxError: invalid syntax

Upvotes: 0

Views: 1245

Answers (2)

user149341
user149341

Reputation:

You have somehow saved a file of Python output -- from a Windows computer! -- to a file named turtle.py on your desktop.

Delete or rename this file. It's conflicting with the turtle module built into Python.

Upvotes: 1

renny
renny

Reputation: 600

The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.

Also, try this.

from turtle import Turtle

Upvotes: 1

Related Questions