Python Forum
from graphics import * - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: from graphics import * (/thread-13495.html)



from graphics import * - jmaloney413 - Oct-17-2018

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()


RE: from graphics import * - Larz60+ - Oct-17-2018

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).


RE: from graphics import * - perfringo - Oct-18-2018

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