[Tutor] easygui question, again

Kent Johnson kent37 at tds.net
Mon Jun 11 12:26:26 CEST 2007


Alan Gauld wrote:
> "Rafael Bejarano" <bejarar at sbcglobal.net> wrote
> 
>> that it would be a relatively simple matter to import the easygui
>> module and call its functions using the terminal window, especially
>> given that I have had success in the past importing other modules 
>> and
>> calling their functions.
> 
> I suspect that this is because you have been using
> the standard library modules which Python knows how to find.
> When you add a downloaded module, like easygui, you need
> to let Python know how to find it. This is done in one of
> three ways:
> 1) Put it in the same folder from which you run python
> 2) Put it in <PYTHON>/lib/site-packages
> 3) Put in in some other folder and add that folder to
>     your PYTHONPATH environment variable setting
> 
> The easiest way for you is probably number 2.
> 
> Try following this procedure:
> 
> 1) Start Python to get a >>> prompt

Which means,
1a) Open Terminal
1b) type python and press return

> 2) import sys
> 3) print sys.path
> 4) use the mouse to select one of the lines that contains 
> "site-packages"

It won't be a line, it will be a long list. Depending on how your Python 
is installed site-packages will be at a location like
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages
or
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages
> 5) Open a Finder window
> 6) Navigate in Finder to the folder highlighted in your Python window
> 7) If necessary navigate back up to site-packages itself
> 8) Create a new sub folder and name it EasyGui
> 9) Copy easygui.py into the new folder
> 10) Create a new text file called EasyGui.pth
> 11) enter the single line "EasyGui" (without the quotes) and save/exit 
> the editor

This will work but instead of 8-11 I would just copy easygui.py into 
site-packages.

Kent

> 12) exit python and enter it again.
> 13) type import easygui at the Python prompt.
> 
> If no error messages appear you should have installed easygui
> where python can see it.
> 
> NB I typed that at my PC so its from memory and untested but
> hopefully its close enough that you can figure out any discrepancies.
> 
> HTH,
> 



More information about the Tutor mailing list