tkbx
tkbx

Reputation: 16275

Include Python library at path?

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.

Upvotes: 1

Views: 918

Answers (1)

Thomas Orozco
Thomas Orozco

Reputation: 55197

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.

Upvotes: 5

Related Questions