My code is:
import scriptlib.abc
import scriptlib.xyz
def foo():
... some operations
but the scriptlib is in some other directory, so I will have to include that directory in environment variable "PYTHONPATH".
Is there anyway in which I can first add the scriptlib directory in environment variable "PYTHONPATH" before import statement getting executed like :
import sys
sys.path.append('/mypath/scriptlib')
import scriptlib.abc
import scriptlib.xyz
def foo():
... some operations
If so, is the value only for that command prompt or is it global ?
Thanks in advance
sys.pathis however local to your program (the$PYTHONPATHvariable is only read when starting the interpreter to fillsys.path, it is not written back to the environment). - filmor