Import python module NOT on path

Posted by Vort3x on Stack Overflow See other posts from Stack Overflow or by Vort3x
Published on 2012-04-15T11:21:00Z Indexed on 2012/04/15 11:29 UTC
Read the original article Hit count: 151

Filed under:
|
|
|
|

I have read all the questions I could find on it on SO, but none answers my question.

I have a module foo, containing util.py and bar.py.

I want to import it in IDLE or python session. How do I go about this?

I could find no documentation on how to import modules not in the current directory or the default python PATH. After trying import "<full path>/foo/util.py", and from "<full path>" import util

The closest I could get was

import imp
imp.load_source('foo.util','C:/.../dir/dir2/foo')

Which gave me Permission denied on windows 7.

© Stack Overflow or respective owner

Related posts about python

Related posts about import