I'm trying to use pywn, a python library for using WordNet. I've played about with python a little under Windows, but am completely new at MacOS X stuff. I'm running under MacOS 10.5.8, so my default Python interpreter is 2.5.1

The pywn instructions say: "Put each of the .py files somewhere in your python search path."

Where is the python search path defined under the default python installation in MacOS X? If I've put the pywn files in /Users/nick/programming/pywn, what is the best way of adding this to the search path? Is this the best place to put the files?

Was it helpful?


I think by default /Library/Python/2.5/site-packages/ is part of your search path. This directory is usually used for third party libraries.


Try print sys.path from a Python shell. This will tell you what directories Python is searching for modules.

It is set via a combination of an environment variable (PYTHONPATH) and a base set of directories specific to your installation.

For more info:

More generally, if you do not have enough administrative rights to modify the system, or if you want to keep some modules in your home directory, you can either do:

import sys
import pywn

You can alternatively add /Users/nick/programming to the environment variable PYTHONPATH, which has the advantage of giving you direct access to pywn through "import pywn". The default place on Mac OS X would be a .bashrc file in your home directory, which should then contain:

export PYTHONPATH="/Users/nick/programming/"

(separate multiple paths with ":", if necessary). You could then access pywn directly from any Python program with a simple "impot pywn".

Simply use:

easy_install [LIBRARY NAME]

By the way... need to be root so before that:

su root
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top