944,092 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 1291
  • Python RSS
Nov 4th, 2009
0

Importing Graphics Module

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SMIFMD is offline Offline
8 posts
since Nov 2009
Nov 5th, 2009
0
Re: Importing Graphics Module
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.
Reputation Points: 930
Solved Threads: 668
Posting Maven
Gribouillis is offline Offline
2,656 posts
since Jul 2008
Nov 5th, 2009
0

Bag magic number

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?"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SMIFMD is offline Offline
8 posts
since Nov 2009
Nov 5th, 2009
0
Re: Importing Graphics Module
Click to Expand / Collapse  Quote originally posted by SMIFMD ...
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.
Reputation Points: 930
Solved Threads: 668
Posting Maven
Gribouillis is offline Offline
2,656 posts
since Jul 2008
Nov 5th, 2009
0
Re: Importing Graphics Module
Thanks a million!!! It works.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SMIFMD is offline Offline
8 posts
since Nov 2009
Nov 5th, 2009
0
Re: Importing Graphics Module
Click to Expand / Collapse  Quote originally posted by SMIFMD ...
Thanks a million!!! It works.
great !
Reputation Points: 930
Solved Threads: 668
Posting Maven
Gribouillis is offline Offline
2,656 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Need help please!
Next Thread in Python Forum Timeline: problem in installing wxwidgets...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC