1

I want to import a module that is not in the Python's search path. I can think of two ways none of which are appealing to me:

  1. add this to the python file import sys; sys.path.append("/path/to/mymodule"); import mymodule
  2. update python path when running the python script PYTHONPATH=$PYTHONPATH:/path/to/mymodule python myfile.py

Is there any better/cleaner way to do this? If not, which one is preferred?

Mohammad Moghimi
  • 4,636
  • 14
  • 50
  • 76

0 Answers0