I did export PYTHONPATH=$PYTHONPATH:/home/User/folder/test
. Then I ran python when I was in /home/User/
and checked sys.path
- it was
If I'm reading your question correctly, you want your data to reside in a location relative to the module. If that's the case, you can use:
full_path = os.path.join(os.path.split(__file__)[:-1]+['pics','text','text.txt'])
__file__
is the path to the module (including modulename.py
). So I split that path, pull off modulename.py
([:-1]
) and add the rest of the relative path via os.path.join