Emacs Python模式和执行命令

Emacs Python模式和执行命令,emacs,python-2.7,emacs24,python-mode,Emacs,Python 2.7,Emacs24,Python Mode,我已经在windows上的C:\ProgramFiles(x64)中安装了emacs24,在C:\Python27 我尝试安装python模式,从emacs向解释器发送命令。Users/myname/.emacs.d中的My init.el文件: (setq py-install-directory "~/.emacs.d/python-mode.el-6.1.1") (add-to-list 'load-path py-install-directory) (require 'python-m

我已经在windows上的
C:\ProgramFiles(x64)
中安装了emacs24,在
C:\Python27

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

(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文件并尝试运行hellow world,如转到菜单PyExec>Execute语句,则会出现以下性质的错误:

打开输出文件:没有这样的文件或目录,c:/Users/Ben/AppData/Local/Temp/c-/Python27/python.exe-705218Y.py


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

您正在使用
setq
自定义设置变量来设置
py shell名称
。如果我没记错的话,
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")
要使用
自定义设置变量
,只需删除
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.
 )

您正在使用
setq
自定义设置变量来设置
py shell名称
。如果我没记错的话,
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")
要使用
自定义设置变量
,只需删除
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.
 )

另一种方法在中开发,另一种方法在中开发