Python Forum
python turtle module in pycharm error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python turtle module in pycharm error
#1
hi guys  

import turtle
def draw_star(size,color):
    count = 0
    angle = 144
    sum1 = 0
   # turtle.bgcolor='black'
    turtle.bgcolor = 'black'
    turtle.pen='yellow'
    while count <= 5:
        for i in (1,5):
            sum1=sum1+45
            if count<5:
                turtle.forward(sum1)
                turtle.right(angle)
            if count>5:
                turtle.forward (-size)
                turtle.right (angle)
        count += 1
    return

draw_star(200,"blue")
This code run in python idle without error. but pycharms cant run this code  Think    

pycharm error:

Traceback (most recent call last):
  File "C:/Users/3DVFX/PycharmProjects/untitled4/turtle.py", line 1, in <module>
    import turtle
  File "C:\Users\3DVFX\PycharmProjects\untitled4\turtle.py", line 21, in <module>
    draw_star(200,"blue")
  File "C:\Users\3DVFX\PycharmProjects\untitled4\turtle.py", line 13, in draw_star
    turtle.forward(sum1)
AttributeError: module 'turtle' has no attribute 'forward'
Reply
#2
Rename turtle.py.
Name is used in bye python to run the module eg ‪C:\Python35\Lib\turtle.py
Reply
#3
(Dec-12-2016, 08:14 PM)snippsat Wrote: Rename turtle.py.
Name is used in bye python to run the module eg ‪C:\Python35\Lib\turtle.py

i rename turtle.py to myturtle.py    Tongue Clap

Thankyou
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pycharm error zuri 1 438 Nov-01-2023, 03:38 PM
Last Post: deanhystad
  Can't update new python version on Pycharm GOKUUUU 6 3,713 Jul-23-2022, 09:24 PM
Last Post: GOKUUUU
  Pandas - error when running Pycharm, but works on cmd line zxcv101 1 1,321 Jun-18-2022, 01:09 PM
Last Post: snippsat
  No module named '_cffi_backend' error with executable not with python script stephanh 2 5,559 Nov-25-2021, 06:52 AM
Last Post: stephanh
  How to use GPU in Python or Pycharm? plumberpy 2 12,918 Oct-11-2021, 12:57 PM
Last Post: plumberpy
  Cannot install tensorflow, numpy etc in Pycharm with Python 3.10 plumberpy 2 3,387 Oct-07-2021, 05:33 AM
Last Post: plumberpy
  PyCharm Error? coder_sw99 4 1,947 Sep-24-2021, 06:16 PM
Last Post: Yoriz
  Module which run in PyCharm but not as exe or terminal. diegoctn 3 6,449 Jul-13-2021, 04:03 AM
Last Post: Harshith
  Keep getting Session management error when running imshow in pycharm pace 0 2,061 Mar-25-2021, 10:06 AM
Last Post: pace
  Python 3 Turtle - Screen Events and Coords peteralien 0 1,652 Aug-18-2020, 11:25 PM
Last Post: peteralien

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020