I thought
import sys
sys.path.append("/home/me/mydir")
is appending a dir to my pythonpath
if I print sys.path my dir is in there.
Then I open a new command and it is not there anymore.
But somehow Python cant import modules I saved in that dir.
What Am I doing wrong?
I read .profile or .bash_profile will do the trick.
Do I have to add:
PATH="/Me//Documents/mydir:$PYTHONPATH"
export PATH
To make it work?
Modifications to
sys.pathonly apply for the life of that Python interpreter. If you want to do it permanently you need to modify thePYTHONPATHenvironment variable:Note that
PATHis the system path for executables, which is completely separate.**You can write the above in
~/.bash_profileand the source it usingsource ~/.bash_profile