繁体   English   中英

emacs和python环境

[英]emacs and python environment

我在// anaconda / bin / python中安装了本地Python

在命令提示符下

$python
>>import sys
>>print sys.executable
>>//anaconda/bin/python

但是,在emacs中,我得到了

M-x shell
bash-3.2$ python
>>import sys
>> print sys.executable
>> /usr/bin/python

如何设置我的路径以在emacs shell中使用所需的Python?

您需要设置emacs使用的PATH环境变量。

查看如何使Emacs识别要编译的bash环境变量?

具体来说就是这样: https : //github.com/purcell/exec-path-from-shell

在OS X上,从图形用户界面启动的Emacs实例将与终端窗口中的Shell具有不同的环境,因为OS X在登录期间未运行Shell。 显然,当从Emacs调用外部实用程序(如make)时,这将导致意外结果。

该库通过从用户的shell复制重要的环境变量来解决此问题。

正如痴呆的刺猬所写,您需要在emacs中修改PATH环境变量。 具体来说,根据您的初始化文件的位置,将此行添加到~/.emacs~/.emacs.d/init.el文件中。

(setenv "PATH"
    (concat
     "//anaconda/bin:"
     (getenv "PATH")
     )
    )

仅出于完整性考虑:在Linux上,仅从shell启动emacs即可读取当前路径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM