似乎 IPython 没有考虑到我的 PYTHONPATH,而普通的 python 解释器会这样做。我在Windows 7上。
我的 PYTHONPATH: C:\workspace\python; C:\Python27\Lib\site-packages\spyderlib; C:\Workspace\Python\awesim\awesim
打印 sys.path:
import sys
for i in sorted(sys.path):
print i
这是我在 IPython 中获得的内容:
C:\JModelica.org-1.8\Python C:\Python27 C:\Python27\DLLs C:\Python27\lib C:\Python27\lib\lib-tk C:\Python27\lib\plat-win C:\Python27 \lib\site-packages C:\Python27\lib\site-packages\PIL C:\Python27\lib\site-packages\Pythonwin C:\Python27\lib\site-packages\ipython-0.13-py2.7.egg C:\Python27\lib\site-packages\ipython-0.13-py2.7.egg\IPython\extensions C:\Python27\lib\site-packages\numpy-1.6.2-py2.7-win32.egg C: \Python27\lib\site-packages\openpyxl-1.5.8-py2.7.egg C:\Python27\lib\site-packages\pandas-0.8.1-py2.7-win32.egg C:\Python27\lib \site-packages\pyzmq-2.2.0.1-py2.7-win32.egg C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg-info C:\Python27\lib\site-包\sphinx-1.1.3-py2.7.egg C:\Python27\lib\site-packages\statsmodels-0.4.0-py2.7-win32.egg C:\Python27\lib\site-packages\tornado- 2.3-py2.7.egg C:\Python27\lib\site-packages\win32 C:\Python27\lib\site-packages\win32\lib C:\Python27\lib\site-packages\wx-2.8-msw-unicode C:\Python27\scripts C:\windows\system32\python27.zip
在 python 控制台中也是如此:
C:\Python27 C:\Python27\DLLs C:\Python27\Lib\site-packages\spyderlib C:\Python27\lib C:\Python27\lib\lib-tk C:\Python27\lib\plat-win C: \Python27\lib\site-packages C:\Python27\lib\site-packages\PIL C:\Python27\lib\site-packages\Pythonwin C:\Python27\lib\site-packages\ipython-0.13-py2.7 .egg C:\Python27\lib\site-packages\numpy-1.6.2-py2.7-win32.egg C:\Python27\lib\site-packages\openpyxl-1.5.8-py2.7.egg C: \Python27\lib\site-packages\pandas-0.8.1-py2.7-win32.egg C:\Python27\lib\site-packages\pyzmq-2.2.0.1-py2.7-win32.egg C:\Python27 \lib\site-packages\setuptools-0.6c11-py2.7.egg-info C:\Python27\lib\site-packages\sphinx-1.1.3-py2.7.egg C:\Python27\lib\site-包\statsmodels-0.4.0-py2.7-win32.egg C:\Python27\lib\site-packages\tornado-2.3-py2.7.egg C:\Python27\lib\site-packages\win32 C:\ Python27\lib\site-packages\win32\lib C:\Python27\lib\site-packages\wx-2.8-msw-unicode C:\Workspace\Python\awesim\awesim C:\windows\system32\python27.zip C:\workspace\python
您可以看到正常的 python 控制台反映了 PYTHONPATH,但 IPython 输出没有。
预先感谢您的线索。