我正在尝试学习为 Python 开发的 Emacs,但我发现我的一些项目由于模块导入问题而无法运行,即未导入 SciPy 或 NumPy。我已经尝试过针对此处提出的相关问题提出的解决方案,例如更改 PYTHONPATH 环境变量,但没有一个是好的。在从终端使用 IDLE 和普通解释器时比较了sys.path,我发现使用了不同的版本:Python-2.7.3 in IDLE
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
==== No Subprocess ====
>>> from pprint import pprint as pp
>>> import sys
>>> pp(sys.path)
['/home/mench',
'/usr/bin',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
和 Python-2.7.2 作为默认系统解释器
Python 2.7.2 (default, Mar 1 2012, 22:28:45)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pprint import pprint as pp
>>> import sys
>>> pp(sys.path)
['',
'/home/mench',
'/opt/alps/lib',
'/usr/local/lib/python27.zip',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/site-packages']
问题是:如何让 Emacs 使用正确版本的 Python?我在 Ubuntu 12.04 上使用 GNU emacs-23.3.1 如果我对问题的假设是错误的,请纠正我