Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help installing graphics library on Mac Python
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
elorah




PostPosted: Wed Dec 01, 2010 9:49 am   Post subject: Need help installing graphics library on Mac Python

I am trying to figure out how to install the graphics library on Mac Python. My teacher told me that on Windows you just copy and paste the graphics.py file into Lib, but we cannot figure out how to do something like that on Mac Python. Do I need a different library (I have the graphics.py file)? Could someone please tell me how to do this? Also if it helps any I am using a MacBook Pro.
Thanks
Sponsor
Sponsor
Sponsor
sponsor
DtY




PostPosted: Wed Dec 01, 2010 9:21 pm   Post subject: RE:Need help installing graphics library on Mac Python

"graphics.py" is not a standard python library. Is this something your teacher gave you?

What you are going to need to do is put that file somewhere in the path. The path is where the python interpreter will look for python files when you import something (the lib directory you mentioned before is in the path). The easiest place to put it would be in the same directory as your python scripts (the path always includes the directory where your python file is), but this may mean having multiple copies of it.

If you open up the python interpreter, sys.path is a list of all the directories in the path:
code:
$ python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/local/lib/wxPython-unicode-2.8.10.1/lib/python2.6/site-packages', '/usr/local/lib/wxPython-unicode-2.8.10.1/lib/python2.6/site-packages/wx-2.8-mac-unicode', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages', '/usr/local/lib/wxPython-unicode-2.8.10.1/lib/python2.6']


You can put the script into any of those. Any of them will work, however some of those directories are meant for modules from a certain package (like the ones with wxpython in the name).

The best choice is probably to put it in the same directory as the os module. You don't need to search for it, if you run help(os) (after importing os), it will tell you where the file is located.

code:
Help on module os:

NAME
    os - OS routines for Mac, NT, or Posix depending on what system we're on.

FILE
    /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.py


In my case, it would be in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/. Yours will probably be the same, or different only by version numbers.

To get to that directory, you can open terminal and run the command open directory, ie. open /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: