Permanently add a directory to PYTHONPATH?

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

    The add a new path to PYTHONPATH is doing in manually by:

    adding the path to your ~/.bashrc profile, in terminal by:

    vim ~/.bashrc
    

    paste the following to your profile

    export PYTHONPATH="${PYTHONPATH}:/User/johndoe/pythonModule"
    

    then, make sure to source your bashrc profile when ever you run your code in terminal:

    source ~/.bashrc 
    

    Hope this helps.

提交回复
热议问题