| | |
Importing Graphics Module
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 26 Days Ago
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; 26 Days Ago 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 26 Days Ago
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; 26 Days Ago 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...
| Thread Tools | Search this Thread |
alarm assignment avogadro beginner bluetooth character cmd code customdialog cx-freeze data decimals dictionary directory dynamic error examples exe file float format function generator getvalue gnu graphics gui halp homework http ideas import input ip itunes java leftmouse line linux list lists logging loop maintain maze millimeter module mouse number numbers output parsing path port prime programming projects push py2exe pygame pyglet pyqt python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation sqlite ssh stdout string strings sudokusolver table terminal text thread threading time tlapse tuple tutorial ubuntu unicode urllib urllib2 variable variables ventrilo verify vigenere web webservice wikipedia wxpython xlib





