Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80900

import graphics library; causes error

Newsgroups comp.lang.python
Date 2014-11-16 12:39 -0800
Message-ID <acf29cb8-d11b-4134-8d03-7be5a078eae6@googlegroups.com> (permalink)
Subject import graphics library; causes error
From ryguy7272 <ryanshuell@gmail.com>

Show all headers | View raw


These libraries drive me totally nuts.  Sorry, just had to get it out there.
Anyway, I open the cmd window, and typed this: 'easy_install python graphics'.  So, it starts up and runs/downloads the appropriate library from the web.  I get confirmation (in the cmd window) that it finishes, then I try to run this script.


# futval_graph2.py
from graphics import *
def main():
  # Introduction
  print "This program plots the growth of a 10-year investment."
  # Get principal and interest rate
  principal = input("Enter the initial principal: ")
  apr = input("Enter the annualized interest rate: ")
  # Create a graphics window with labels on left edge
  win = GraphWin("Investment Growth Chart", 640, 480)
  win.setBackground("white")
  win.setCoords(-1.75,-200, 11.5, 10400)
  Text(Point(-1, 0), '0.0K').draw(win)
  Text(Point(-1, 2500), '2.5K').draw(win)
  Text(Point(-1, 5000), '5.0K').draw(win)
  Text(Point(-1, 7500), '7.5k').draw(win)
  Text(Point(-1, 10000), '10.0K').draw(win)
  # Draw bar for initial principal
  bar = Rectangle(Point(0, 0), Point(1, principal))
  bar.setFill("green")
  bar.setWidth(2)
  bar.draw(win)
  # Draw a bar for each subsequent year
  for year in range(1, 11):
    principal = principal * (1 + apr)
    bar = Rectangle(Point(year, 0), Point(year+1, principal))
    bar.setFill("green")
    bar.setWidth(2)
    bar.draw(win)
  raw_input("Press <Enter> to quit.")


After I hit F5, I get this:
Traceback (most recent call last):
  File "C:\Users\Ryan\Desktop\Graphics_Test.py", line 2, in <module>
    from graphics import *
ImportError: No module named graphics

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

import graphics library; causes error ryguy7272 <ryanshuell@gmail.com> - 2014-11-16 12:39 -0800
  Re: import graphics library; causes error Terry Reedy <tjreedy@udel.edu> - 2014-11-16 18:09 -0500
  Re: import graphics library; causes error ryguy7272 <ryanshuell@gmail.com> - 2014-11-16 19:03 -0800
    Re: import graphics library; causes error Chris Angelico <rosuav@gmail.com> - 2014-11-17 14:11 +1100
    Re: import graphics library; causes error Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-17 21:24 +1100
    Re: import graphics library; causes error Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-17 12:14 +0000
    Re: import graphics library; causes error YBM <ybmess@nooos.fr.invalid> - 2014-11-17 13:21 +0100
  Re: import graphics library; causes error Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-17 00:35 -0700

csiph-web