How to import modules from site-packages when in a different directory?
There is two ways to make python find your module:
- add the path where you module reside in your
PYTHONPATH
as suggested by bmat - add the path where you module reside in your script like this:
import syssys.path.insert(0, '/root/Downloads/Python-3.5.2/Lib/site-packages')
Instead of moving the module I would suggest you add the location of the module to the PYTHONPATH
environment variable. If this is set then the python interpreter will know where to look for your module.
e.g. on Linux
export PYTHONPATH=$PYTHONPATH:<insert module location here>
Instead of moving the module I would suggest you add the location of the module to the PYTHONPATH environment variable. If this is set then the python interpreter will know where to look for your module.
e.g. on Linux
export PYTHONPATH=$PYTHONPATH: