David Williams
David Williams

Reputation: 8654

Python: Add to Include Path on the Command Line

Is there a way to add include paths to python on the command line? What I am trying to do is run a unit test that uses a some code in a lib directory:

$ python -I lib/ test/my-test.py

but this fails. I can append to my path in my-test.py but that seems less than optimal since its path dependent. Any suggestions?

Upvotes: 0

Views: 1713

Answers (2)

Andrew Clark
Andrew Clark

Reputation: 208555

I don't believe there is a command line switch for this, but you can just set the PYTHONPATH environment variable to include the lib directory:

PYTHONPATH=$PYTHONPATH:`pwd`/lib/ python test/my-test.py

Upvotes: 1

Martijn Pieters
Martijn Pieters

Reputation: 1123480

Use the PYTHONPATH environment variable:

PYTHONPATH=lib/ python test/my-test.py

Upvotes: 2

Related Questions