Permanently add a directory to PYTHONPATH?

前端 未结 19 1324
别那么骄傲
别那么骄傲 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:38

    Adding export PYTHONPATH="${PYTHONPATH}:/my/other/path" to the ~/.bashrc might not work if PYTHONPATH does not currently exist (because of the :).

    export PYTHONPATH="/my/other/path1"
    export PYTHONPATH="${PYTHONPATH}:/my/other/path2"
    

    Adding the above to my ~/.bashrc did the trick for me on Ubuntu 16.04

提交回复
热议问题