我在 // 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的路径?
答案 0 :(得分:0)
您需要设置emacs使用的PATH环境变量。
退房 How do I make Emacs recognize bash environment variables for compilation?
具体来说: https://github.com/purcell/exec-path-from-shell
在OS X上,Emacs实例从图形用户界面启动 将在终端窗口中具有与shell不同的环境, 因为OS X在登录期间不运行shell。显然这个 调用外部实用程序时会导致意外结果 来自Emacs。
这个库通过复制重要来解决这个问题 来自用户shell的环境变量。
答案 1 :(得分:0)
正如痴呆hedgehog所写,你需要在emacs中修改你的PATH环境变量。具体来说,请在~/.emacs
或~/.emacs.d/init.el
文件中添加此行,具体取决于初始文件的位置。
(setenv "PATH"
(concat
"//anaconda/bin:"
(getenv "PATH")
)
)
答案 2 :(得分:0)
为了完整起见:在Linux上,只需从shell启动emacs即可读取当前路径。