当我在IPython中打印sys.path
时,我惊讶地看到在第二个位置(bin
)插入了python安装的sys.path[1]
。
~> /opt/local/bin/ipython -c "import sys; [print(p) for p in sys.path]"
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload
/Users/kenter/Library/Python/3.4/lib/python/site-packages
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/extensions
/Users/kenter/.ipython
Out[1]: [None, None, None, None, None, None, None, None, None, None]
我指的是/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin
目录。当我使用常规python打印时,它不存在。
~> /opt/local/bin/python -c "import sys; [print(p) for p in sys.path]"
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload
/Users/kenter/Library/Python/3.4/lib/python/site-packages
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
那么,为什么IPython会将bin
目录添加到sys.path
?这是为了什么目的?
这对我没有任何问题,我只是好奇。