Permanently add a directory to PYTHONPATH?

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

    This works on Windows

    1. On Windows, with Python 2.7 go to the Python setup folder.
    2. Open Lib/site-packages.
    3. Add an example.pth empty file to this folder.
    4. Add the required path to the file, one per each line.

    Then you'll be able to see all modules within those paths from your scripts.

提交回复
热议问题