1

Is there a way to import a Python library at a certain path? For example,

import os, sys, etc
import "/path/to/lib.py"

I'd like to include a library with a python file, and other than making them install the library, this is the best way I can think of.

tkbx
  • 15,602
  • 32
  • 87
  • 122

1 Answers1

5

You could do:

sys.path.append('/path/to')
import lib

But, to be honest, you shouldn't.
It's pretty easy to install a library, especially using tools such as virtualenv and pip.

Thomas Orozco
  • 53,284
  • 11
  • 113
  • 116