python modules path

  • 查看当前python的模块路径

    1
    2
    3
    >>> import sys
    >>> print(sys.path)
    ['', '/root/.pyenv/versions/2.7.13/lib/python27.zip', '/root/.pyenv/versions/2.7.13/lib/python2.7', '/root/.pyenv/versions/2.7.13/lib/python2.7/plat-linux2', '/root/.pyenv/versions/2.7.13/lib/python2.7/lib-tk', '/root/.pyenv/versions/2.7.13/lib/python2.7/lib-old', '/root/.pyenv/versions/2.7.13/lib/python2.7/lib-dynload', '/root/.pyenv/versions/2.7.13/lib/python2.7/site-packages']
  • 添加模块路径

    1
    [root@localhost ~]# export PYTHONPATH=/path/to/pylib:$PYTHONPATH