Spacemacs 将 python shell 设置为 Anaconda3 路径

Spacemacs set python shell to Anaconda3 path

我已经开始使用 Spacemacs 编辑 python 文件并使用组织模式,但现在我想从 Spacemacs 运行 python 而不是 运行ning Anaconda 提示符。

我在 .spacemacs 文件中用 SPC f e d 写了这个:

(defun dotspacemacs/user-init ()
  "Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
 This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
  (setq python-shell-interpreter "C:/Users/Mahesvara/Documents/Personal_Documents/Programs/Anaconda3/python.exe")
  )

但是当我尝试 运行 带有 C-c C-p 的脚本时,出现以下错误:Searching for program: No such file or directory, python

我对 Windows 上的 Spacemacs 并不完全熟悉,但这是我的目标...

命令行不是 shell

请注意,anaconda 提示符不是 shell,它是 anaconda (see here) 的命令提示符界面。

Windows 使用 cmd。 Spacemacs、Unix和Python使用shells,是完全不同的接口。

欢迎来到 Spacemacs

您放入该变量的内容不应是文件路径。它应该是一个程序的名称。 Emacs 有一个存储可执行文件的位置列表。 这个变量叫做 exec-pathHere就是怎么设置的。

我建议不要修改它,而是查看它

(print exec-path)

其中一个路径(即 python、ipython 等)中需要 python shell。

更有经验的 Windows 开发人员可能不同意这一点。但是安装一些 Babun/Cygwin shell 来安装 python 可能会有所帮助。特别是如果您使用的是 Spacemacs。这将允许您 运行 在更适合 Spacemacs 的 Unix-y 环境中。只需确保主目录匹配即可。

一旦您在 exec-path 之一中安装了 python shell 程序, 您应该能够:

(setq python-shell-interpreter "python")

将 python 更改为您选择的 python shell。