sys.path() and PYTHONPATH issues

后端 未结 3 1443
长情又很酷
长情又很酷 2021-01-05 22:05

I\'ve been learning Python, I\'m working in 2.7.3, and I\'m trying to understand import statements.

  1. The documentation says that when you attemp

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-05 22:45

    So many questions in one go! :)

    Well I try to answer only a few of them.

    1) a built-in module is any module that comes with a python release. For instance the sys and os modules are built-in modules. That's it really.

    2) The PYTHONPATH variable don't exist by default on your system. When you launch the python interpreter, it fills the array of path where it search for modules, in the way you described. This is the result of sys.path. However sys.path is not the environment variable PYTHONPATH. If you set the PYTHONPATH in your system, then all the path contained in it will be included in the array that python's interpreter uses to search for modules.

    I will leave the answer to the environment variables for others, as I don't feel I'm the right person to answer such a question. My feeling though, is that it might change from system to system. Anyway...

    Hope it helps.

提交回复
热议问题