open() can't find file given path relative to PYTHONPATH

后端 未结 3 832
暖寄归人
暖寄归人 2021-01-16 07:38

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

3条回答
  •  再見小時候
    2021-01-16 08:10

    Whenever I want to import a script, relative to current and don't use packages, I usually use

    sys.path = [os.path.dirname(__file__) + "/../another_dir"] + sys.path
    

提交回复
热议问题