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.

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.

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?"

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.

Thanks a million!!! It works.

Thanks a million!!! It works.

great !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.