[Tutor] easygui question, again

Alan Gauld alan.gauld at btinternet.com
Mon Jun 11 09:36:13 CEST 2007


"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
2) import sys
3) print sys.path
4) use the mouse to select one of the lines that contains 
"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
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,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list