Permanently add a directory to PYTHONPATH?

前端 未结 19 1305
别那么骄傲
别那么骄傲 2020-11-22 01:12

Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I

19条回答
  •  鱼传尺愫
    2020-11-22 01:33

    For me it worked when I changed the .bash_profile file. Just changing .bashrc file worked only till I restarted the shell.

    For python 2.7 it should look like:

    export PYTHONPATH="$PYTHONPATH:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
    

    at the end of the .bash_profile file.

提交回复
热议问题