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

后端 未结 3 842
暖寄归人
暖寄归人 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:02

    Open is relative to the current directory and does not use PYTHONPATH. The current directory defaults to whatever it was when python was started on the command line.

    You can change the current directory with os.chdir

提交回复
热议问题