Sunday, December 23, 2012

Python module search path


Recently a coworker came to me asking why after installing a module via pip that he couldn't import it into python.

Turns out pip was installing to a directory that wasn't in the search path aka sys.path

You can check your sys.path by saying "import sys" followed by "sys.path"

Make sure the directory pip is installing your module into is in sys.path

Here pass the "-v" to pip to find out where it installed the module like so:

sudo pip install nltk -v

http://docs.python.org/2/tutorial/modules.html

No comments:

Post a Comment