Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 from graphics import *
#1
I am attempting to follow a tutorial however my code keeps failing in the first line.
"setBackground" and "color_rgb()" both auto filled so I know that my import has worked and it is recognizing "graphics".
However my code is still failing in the first line with this return.
Traceback (most recent call last):
File "C:/First_Try/main.py", line 1, in <module>
from graphics import *

from graphics import *
def main():
win=GraphWin("My Window",500,500)
win.setBackground(color_rgb(255,0,0))

win.getMouse()
win.close()

main()
Quote
#2
The error message is telling you that it can't find the 'graphics' package.
there is one here: https://github.com/olls/graphics
if this is what you are trying to use, install with:
pip install graphics
then go to the URL above, read the README.md in which there are examples,
then look in the directory examples (on same web page).
Quote
#3
While doing that pip install per Larz60+ suggestion it's worth to check Python documentation regarding import best practices: What are the “best practices” for using import in a module?. Especially:

Quote:In general, don’t use from modulename import *. Doing so clutters the importer’s namespace
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Graphics py not found vnc 13 7,792 Apr-05-2017, 05:36 PM
Last Post: wavic

Forum Jump:


Users browsing this thread: 1 Guest(s)