| | |
Importing Graphics Module
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
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.
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.
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.
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.
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
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?"
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?"
0
#4 Nov 5th, 2009
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.
![]() |
Similar Threads
- "_imaging C module is not installed" thrown in PIL (Python)
- taxation gui module (Python)
- A multilingual coded Hello World! thread (Legacy and Other Languages)
- Need help getting text to display in a graphics window (Python)
- Graphics help... (Python)
- Tkinter Button(s) (Python)
- Did I do this correctly..Due in 11hrs..Can this program be written in other ways? (Python)
- Question on HW problem (Python)
- How to prevent statement execution when importing modules? (Python)
Other Threads in the Python Forum
- Previous Thread: Need help please!
- Next Thread: problem in installing wxwidgets...
Views: 333 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied address ansi backend beginner changecolor class code conversion coordinates copy curves customdialog dan08 dictionary directory dynamic edit examples excel feet file float font format ftp function generator getvalue gui halp homework i/o images import info input ip java line linux list lists loop mouse mysql newb number numbers output panel parsing path port prime print program programming projects py2exe pygame pyqt python queue random rational recursion recursive schedule screensaverloopinactive scrolledtext searchingfile server ssh stamp statictext string strings sudokusolver table terminal text thread threading time tkinter tlapse tuple tutorial type ubuntu unicode url urllib urllib2 variable whileloop windows write wxpython





