Monday, March 18, 2013

Add Packages for importing to python

Add the package directly to a directory already in the sys.path
1. Find the directory /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages

2. If this folder is hinden in finder and you would like to see it just follow these steps:
    a.  open find
    b.  press shift-Command-G
    c. this brings up a ''go to folder" dialog
    d. Type in the name of the directory.
    e. Then I just dragged this folder under Favorites on the left menu bar.


3.  Now that I just created a test program called hello_world.py
4. I placed hello_world.py in /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages


    def add(A, B):
       print (A + B)


5. opened idle and typed the below commands.

>>> import hello_world
>>> hello_world.add(5,3)
8
>>>

6. now I can import hello_world.add() any time.  I'm now on my way to install any modules.


Add a directory to sys.path