Windows 8 + Emacs 24.3 + emacs-for-python:Pymacs帮助器在30秒内没有启动

时间:2013-06-06 22:23:34

标签: python windows emacs

我最近安装了Emacs 24.3并尝试使用它编写Python(v3.3.2 x86-64 MSI安装程序)。 (我是Emacs的新手)。然后我尝试通过将zip解压缩到

来安装emacs-for-python
"C:\Users\mmsc\AppData\Roaming\.emacs.d\emacs-for-python" 

文件夹并添加

: (load-file "~/.emacs.d/emacs-for-python/epy-init.el") 

进入C:\ Users \ mmsc \ AppData \ Roaming.emacs

启动Emacs后,我看到错误

  

警告(初始化):加载时发生错误   `C:/Users/Klein/AppData/Roaming/.emacs':

     

错误:Pymacs助手未在30秒内启动

     

为确保正常操作,您应该调查并删除   初始化文件中的错误原因。用。启动Emacs   `--debug-init'选项查看完整的错误回溯。

使用“--debug-init”,我看到了以下信息,但我对Emacs / Lisp知之甚少,所以我无法轻易找到问题。

Debugger entered--Lisp error: (error "Pymacs helper did not start within 30 seconds")
  signal(error ("Pymacs helper did not start within 30 seconds"))
  pymacs-report-error("Pymacs helper did not start within %d seconds" 30)
  (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))
  (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\)  " nil t))) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start)))
  (let ((process (apply (quote start-process) "pymacs" buffer (let ((python (getenv "PYMACS_PYTHON"))) (if (or (null python) (equal python "")) pymacs-python-command python)) "-c" (concat "import sys;" " from Pymacs import main;" " main(*sys.argv[1:])") (append (and (>= emacs-major-version 24) (quote ("-f"))) (mapcar (quote expand-file-name) pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\)  " nil t))) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number (match-string 1))))) (while (< (marker-position marker) limit-position) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper probably was interrupted at start")))))
  (progn (let ((process (apply (quote start-process) "pymacs" buffer (let ((python ...)) (if (or ... ...) pymacs-python-command python)) "-c" (concat "import sys;" " from Pymacs import main;" " main(*sys.argv[1:])") (append (and (>= emacs-major-version 24) (quote ...)) (mapcar (quote expand-file-name) pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\)   " nil t))) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number (match-string 1))))) (while (< (marker-position marker) limit-position) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (if (string-equal (cadr reply) "0.25") nil (pymacs-report-error "Pymacs Lisp version is 0.25, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply"))))
  (unwind-protect (progn (let ((process (apply (quote start-process) "pymacs" buffer (let (...) (if ... pymacs-python-command python)) "-c" (concat "import sys;" " from Pymacs import main;" " main(*sys.argv[1:])") (append (and ... ...) (mapcar ... pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\)  " nil t))) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number ...)))) (while (< (marker-position marker) limit-position) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (if (string-equal (cadr reply) "0.25") nil (pymacs-report-error "Pymacs Lisp version is 0.25, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply")))) (set-match-data save-match-data-internal (quote evaporate)))
  (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((process (apply (quote start-process) "pymacs" buffer (let ... ...) "-c" (concat "import sys;" " from Pymacs import main;" " main(*sys.argv[1:])") (append ... ...)))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\)   " nil t))) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ ... ...))) (while (< (marker-position marker) limit-position) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (if (string-equal (cadr reply) "0.25") nil (pymacs-report-error "Pymacs Lisp version is 0.25, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply")))) (set-match-data save-match-data-internal (quote evaporate))))
  (save-current-buffer (set-buffer buffer) (erase-buffer) (buffer-disable-undo) (pymacs-set-buffer-multibyte nil) (set-buffer-file-coding-system (quote raw-text)) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((process (apply ... "pymacs" buffer ... "-c" ... ...))) (pymacs-kill-without-query process) (while (progn (goto-char ...) (not ...)) (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker ...) (limit-position ...)) (while (< ... limit-position) (if ... nil ...)))) (goto-char (match-end 0)) (let ((reply (read ...))) (if (and (pymacs-proper-list-p reply) (= ... 2) (eq ... ...)) (if (string-equal ... "0.25") nil (pymacs-report-error "Pymacs Lisp version is 0.25, Python is %s" ...)) (pymacs-report-error "Pymacs got an invalid initial reply")))) (set-match-data save-match-data-internal (quote evaporate)))))
  (let ((buffer (get-buffer-create "*Pymacs*"))) (save-current-buffer (set-buffer buffer) (erase-buffer) (buffer-disable-undo) (pymacs-set-buffer-multibyte nil) (set-buffer-file-coding-system (quote raw-text)) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((process ...)) (pymacs-kill-without-query process) (while (progn ... ...) (if ... nil ...)) (let (... ...) (while ... ...))) (goto-char (match-end 0)) (let ((reply ...)) (if (and ... ... ...) (if ... nil ...) (pymacs-report-error "Pymacs got an invalid initial reply")))) (set-match-data save-match-data-internal (quote evaporate))))) (if (not pymacs-use-hash-tables) (setq pymacs-weak-hash t) (if pymacs-used-ids (progn (let ((pymacs-transit-buffer buffer) (pymacs-forget-mutability t) (pymacs-gc-inhibit t)) (pymacs-call "zombie_python" pymacs-used-ids)) (setq pymacs-used-ids nil))) (setq pymacs-weak-hash (make-hash-table :weakness (quote value))) (if (boundp (quote post-gc-hook)) (add-hook (quote post-gc-hook) (quote pymacs-schedule-gc)) (setq pymacs-gc-timer (run-at-time 20 20 (quote pymacs-schedule-gc))))) (setq pymacs-transit-buffer buffer) (let ((modules pymacs-load-history)) (setq pymacs-load-history nil) (if (and modules (yes-or-no-p "Reload modules in previous session? ")) (progn (mapc (function (lambda (args) (condition-case err ... ...))) modules)))))
  pymacs-start-services()
  (if (and pymacs-transit-buffer (buffer-name pymacs-transit-buffer) (get-buffer-process pymacs-transit-buffer)) nil (if pymacs-weak-hash (progn (if (or (eq pymacs-auto-restart t) (and (eq pymacs-auto-restart (quote ask)) (yes-or-no-p "The Pymacs helper died.  Restart it? "))) nil (pymacs-report-error "There is no Pymacs helper!")))) (pymacs-start-services))
  pymacs-serve-until-reply("eval" (pymacs-print-for-apply (quote "pymacs_load_helper") (quote ("ropemacs" "rope-" nil))))
  pymacs-call("pymacs_load_helper" "ropemacs" "rope-" nil)
  (let ((lisp-code (pymacs-call "pymacs_load_helper" module prefix noerror))) (cond (lisp-code (let ((result (eval lisp-code))) (add-to-list (quote pymacs-load-history) (list module prefix noerror) (quote append)) (message "Pymacs loading %s...done" module) (run-hook-with-args (quote pymacs-after-load-functions) module) result)) (noerror (message "Pymacs loading %s...failed" module) nil)))
  pymacs-load("ropemacs" "rope-")
  setup-ropemacs()
  (progn (setup-ropemacs) (autoload (quote virtualenv-activate) "virtualenv" "Activate a Virtual Environment specified by PATH" t) (autoload (quote virtualenv-workon) "virtualenv" "Activate a Virtual Environment present using virtualenvwrapper" t) (add-hook (quote python-mode-hook) (lambda nil (if (buffer-file-name) (flymake-mode)))) (defun workon-postactivate (virtualenv) (require (quote virtualenv)) (virtualenv-activate virtualenv) (desktop-change-dir virtualenv)))
  (lambda nil (progn (setup-ropemacs) (autoload (quote virtualenv-activate) "virtualenv" "Activate a Virtual Environment specified by PATH" t) (autoload (quote virtualenv-workon) "virtualenv" "Activate a Virtual Environment present using virtualenvwrapper" t) (add-hook (quote python-mode-hook) (lambda nil (if (buffer-file-name) (flymake-mode)))) (defun workon-postactivate (virtualenv) (require (quote virtualenv)) (virtualenv-activate virtualenv) (desktop-change-dir virtualenv))))()
  funcall((lambda nil (progn (setup-ropemacs) (autoload (quote virtualenv-activate) "virtualenv" "Activate a Virtual Environment specified by PATH" t) (autoload (quote virtualenv-workon) "virtualenv" "Activate a Virtual Environment present using virtualenvwrapper" t) (add-hook (quote python-mode-hook) (lambda nil (if (buffer-file-name) (flymake-mode)))) (defun workon-postactivate (virtualenv) (require (quote virtualenv)) (virtualenv-activate virtualenv) (desktop-change-dir virtualenv)))))
  eval((funcall (quote (lambda nil (progn (setup-ropemacs) (autoload (quote virtualenv-activate) "virtualenv" "Activate a Virtual Environment specified by PATH" t) (autoload (quote virtualenv-workon) "virtualenv" "Activate a Virtual Environment present using virtualenvwrapper" t) (add-hook (quote python-mode-hook) (lambda nil (if (buffer-file-name) (flymake-mode)))) (defun workon-postactivate (virtualenv) (require (quote virtualenv)) (virtualenv-activate virtualenv) (desktop-change-dir virtualenv)))))))
  eval-after-load(python (progn (setup-ropemacs) (autoload (quote virtualenv-activate) "virtualenv" "Activate a Virtual Environment specified by PATH" t) (autoload (quote virtualenv-workon) "virtualenv" "Activate a Virtual Environment present using virtualenvwrapper" t) (add-hook (quote python-mode-hook) (lambda nil (if (buffer-file-name) (flymake-mode)))) (defun workon-postactivate (virtualenv) (require (quote virtualenv)) (virtualenv-activate virtualenv) (desktop-change-dir virtualenv))))
  eval-buffer(#<buffer  *load*-819053> nil "c:/Users/mmsc/AppData/Roaming/.emacs.d/emacs-for-python/epy-python.el" nil t)  ; Reading at buffer position 4662
  load-with-code-conversion("c:/Users/mmsc/AppData/Roaming/.emacs.d/emacs-for-python/epy-python.el" "c:/Users/mmsc/AppData/Roaming/.emacs.d/emacs-for-python/epy-python.el" nil t)
  require(epy-python)
  eval-buffer(#<buffer  *load*-283406> nil "c:/Users/mmsc/AppData/Roaming/.emacs.d/emacs-for-python/epy-init.el" nil t)  ; Reading at buffer position 476
  load-with-code-conversion("c:/Users/mmsc/AppData/Roaming/.emacs.d/emacs-for-python/epy-init.el" "c:/Users/mmsc/AppData/Roaming/.emacs.d/emacs-for-python/epy-init.el" nil nil)
  load("c:/Users/mmsc/AppData/Roaming/.emacs.d/emacs-for-python/epy-init.el" nil nil t)
  load-file("C:\\Users\\mmsc\\AppData\\Roaming\\.emacs.d\\emacs-for-python\\epy-init.el")
  eval-buffer(#<buffer  *load*> nil "c:/Users/mmsc/AppData/Roaming/.emacs" nil t)  ; Reading at buffer position 656
  load-with-code-conversion("c:/Users/mmsc/AppData/Roaming/.emacs" "c:/Users/mmsc/AppData/Roaming/.emacs" t t)
  load("~/.emacs" t t)

我试图从互联网上搜索一些帮助,但大多数都是针对Linux / Unix的环境。有没有人在Windows下使用Emacs和Python,知道这是什么意思,我该如何解决?

谢谢!

2 个答案:

答案 0 :(得分:1)

这对评论来说有点太多了:

    (let ((process
           (apply 'start-process "pymacs" buffer
                  (let ((python (getenv "PYMACS_PYTHON")))
                    (if (or (null python) (equal python ""))
                        pymacs-python-command
                      python))
                  "-c" (concat "import sys;"
                               " from Pymacs import main;"
                               " main(*sys.argv[1:])")
                  (append
                   (and (>= emacs-major-version 24) '("-f"))
                   (mapcar 'expand-file-name pymacs-load-path)))))

这是在*Pymacs*缓冲区中启动进程的Pymacs代码。您可以从中推断出Pymacs将首先搜索环境变量$PYMACS_PYTHON,如果它不存在或者它的值是空字符串,那么它将尝试pymacs-python-command,默认情况下为{{1} }}。所以,它会打这个电话:

"python"

$ python -c 'import sys; from Pymacs import main; main(*sys.argv[1:])' 存在问题 - 我不知道哪个版本的Python接受这个参数,但是我接受的那个版本没有。这段代码的意图非常明确 - 可能它必须加载-f上的文件,但对我来说这个变量的值是pymacs-load-path - 所以我不认为这个代码会运行。无论如何,这个论点似乎并没有伤害,因为它启动时有或没有它。

因此,如果您尝试在控制台中运行上述命令,并获得类似的内容:

nil

然后这段代码工作正常,否则,你会收到一些错误,这有助于你找出问题所在。请记住,它可能不只是(version "0.25") 。它可以是python$PYMACS_PYHON

答案 1 :(得分:0)

我有相同的症状,但我的问题原来是一个旧的pymacs.el和一个新的Pymacs。显然,Pymacs改变了模块接口,我不得不去寻找流浪的pymacs.el。所以pymacs.el是由apt-get安装在一个奇怪的位置。您必须确保字节代码文件也已消失。