Permanently add a directory to PYTHONPATH?

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

    In case anyone is still confused - if you are on a Mac, do the following:

    1. Open up Terminal
    2. Type open .bash_profile
    3. In the text file that pops up, add this line at the end: export PYTHONPATH=$PYTHONPATH:foo/bar
    4. Save the file, restart the Terminal, and you're done

提交回复
热议问题