Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Python Path Hacks

Published on

Updated on

Warning: This post has not been modified for over 2 years. For technical posts, make sure that it is still relevant.

There are two quick ways to hack together custom imports in Python. One is by using the PYTHONPATH environmental variable, and the other way is by using the sys module in Python.


Before you call python set the environmental variable.


Then you can call python.

Method 2: sys

In the beginning of your Python script add the following code.

import sys


Of course this isn’t the best way to add custom libraries to your Python scripts. Ideally, we would use pip to manage our dependencies. Perhaps a future blog post will cover this!

Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :