faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 11 people (91%) answered Yes
Recently 6 of 7 people (86%) answered Yes

Entry

How do I import a file that isn't in the pythonpath?

Jul 5th, 2003 12:26
Alain Tesio, unknown unknown, Mike 'Cat' Perkonigg


The easiest way is to put '.' in your PYTHONPATH.
But you can extend your path with any directory in your python code 
with:
>>>import sys
>>>sys.path.append (path-to-load-modules-from)
If you don't want to change your python path, there are functions in the
imp module to import a module if you know its path.