0

C:\Program Files(x64)我在windows中和python2.7下安装了emacs24C:\Python27

我尝试安装 python 模式以从 emacs 向解释器发送命令。我的 init.el 文件位于Users/myname/.emacs.d

(setq py-install-directory "~/.emacs.d/python-mode.el-6.1.1")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)
(setq py-shell-name "C:\Python27\python.exe")

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(py-shell-name "C:\\Python27\\python.exe"))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

我已将 python 模式文件放入:C:\Users\myname\.emacs.d\python-mode.el-6.1.1

通过在菜单中选择 PyShell > Default Intepreter 选项,可以在缓冲区中形成交互式 python 会话,但是如果我打开一个 .py 文件并尝试通过转到菜单 PyExec > Execute Statement 来运行一个地狱般的世界,我会收到错误这种性质的:

Opening output file: no such file or directory, c:/Users/Ben/AppData/Local/Temp/C-/Python27/python.exe-705218Y.py

如何设置以便我可以编辑 python 代码,然后将行发送到另一个缓冲区中的 python 解释器而不会出现此错误?

4

1 回答 1

3

您正在使用setqandcustom-set-variables来设置py-shell-name. 如果我没记错的话,custom-set-variables如果你在它之前使用它是行不通的setq。此外,当您用字符串文字编写它时,您需要转义反斜杠。使用以下方法之一应该可以解决您的问题。

要使用setq,请修复反斜杠:

(setq py-install-directory "~/.emacs.d/python-mode.el-6.1.1")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)
(setq py-shell-name "C:\\Python27\\python.exe")

要使用custom-set-variables,只需删除setq

(setq py-install-directory "~/.emacs.d/python-mode.el-6.1.1")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(py-shell-name "C:\\Python27\\python.exe"))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
于 2013-03-08T05:37:17.573 回答