Importing Graphics Module

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Nov 2009
Posts: 4
Reputation: SMIFMD is an unknown quantity at this point 
Solved Threads: 0
SMIFMD SMIFMD is offline Offline
Newbie Poster

Importing Graphics Module

 
0
  #1
Nov 4th, 2009
Greetings!

I am in need of some techincal assistance. My problem is as follows:

In my Programming class, we are starting to use the graphics package in Python. We are using a module called graphics.py

In order to use this module, we have to save it to the desktop and import it in our program (i.e., from graphics import *). However, this only works on the computers at school; when I attempt to import the graphics module on my personal computer, an error message appears stating that the graphics module cannot be found.

When asked, my Prof. stated that I need to place it some place that Python can find it. Needless-to-say, it's not working.

Can anybody who is more savvy with Python tell me how to do this? I am at a lose and about to pull my hair out.

Thank you.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 983
Reputation: Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough 
Solved Threads: 222
Gribouillis's Avatar
Gribouillis Gribouillis is online now Online
Posting Shark
 
0
  #2
Nov 5th, 2009
A simple thing to do is to put the file "graphics.py" in a folder named "site-packages" which is a subfolder of your python Lib folder. You should locate it easily on your computer.

Another solution is to create another folder where you want to put importable modules, for example "C:/pymods" (if you're using windows) or "$HOME/pymods" (if you're using linux) and set an environment variable PYTHONPATH to the value "C:/pymods" (or "$HOME/pymods"), and then put the graphics.py in your folder pymods.
Last edited by Gribouillis; Nov 5th, 2009 at 12:38 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 4
Reputation: SMIFMD is an unknown quantity at this point 
Solved Threads: 0
SMIFMD SMIFMD is offline Offline
Newbie Poster

Bag magic number

 
0
  #3
Nov 5th, 2009
When I placed the graphics.py file in the "site packages" folder, the following error appears:

Traceback (most recent call last):
File "G:\CSI 31\house.py", line 4, in <module>
from graphics import *
ImportError: Bad magic number in C:\Python26\lib\site-packages\graphics.pyc

What is "Bad magic number?"
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 983
Reputation: Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough 
Solved Threads: 222
Gribouillis's Avatar
Gribouillis Gribouillis is online now Online
Posting Shark
 
0
  #4
Nov 5th, 2009
Originally Posted by SMIFMD View Post
ImportError: Bad magic number in C:\Python26\lib\site-packages\graphics.pyc

What is "Bad magic number?"
Did you place a 'graphics.py' (good) or a 'graphic.pyc' (bad) in the site-packages folder ? Try to remove the '.pyc' and run again, it may work. Otherwise, you can attach graphics.py to a post, so that I try it with my python 2.6.
Last edited by Gribouillis; Nov 5th, 2009 at 1:58 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 4
Reputation: SMIFMD is an unknown quantity at this point 
Solved Threads: 0
SMIFMD SMIFMD is offline Offline
Newbie Poster
 
0
  #5
Nov 5th, 2009
Thanks a million!!! It works.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 983
Reputation: Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough 
Solved Threads: 222
Gribouillis's Avatar
Gribouillis Gribouillis is online now Online
Posting Shark
 
0
  #6
Nov 5th, 2009
Originally Posted by SMIFMD View Post
Thanks a million!!! It works.
great !
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 331 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC