【问题标题】:No prompt in ipython when launched in emacs在 emacs 中启动时 ipython 中没有提示
【发布时间】:2014-09-25 14:50:46
【问题描述】:

我尝试通过在编辑 python 脚本时键入 C-c C-p 在 emacs 上启动 ipython 控制台。但是 ipython 控制台看起来是空白的。虽然当我键入一些命令时,会有一个输出并显示 Out 提示。此外,当我 exit() 时,会显示许多 In() 提示。为什么会这样?

我使用的是 emacs 版本 24.3、ipython 2.1.0 和 python 2.7.6。以下是我的 init.el

;;; To start emacs maximized at startup
(w32-send-sys-command 61488)


;;; To remove the toolbar from emacs
(tool-bar-mode 0)


;;; IDO configuration
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)


;;; Add MELPA repository
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)


;;; Configure Aspell
(add-to-list 'exec-path "C:/Program Files (x86)/Aspell/bin/")
; Tell emacs to use Aspell and provide the location of custom dictionary
(setq ispell-program-name "aspell")
(setq ispell-personal-dictionary "C:/emacs/.emacs.d/my_dict/my_dict.ispell")
; Turn it on
(require 'ispell)


;;; Flyspell configuration
(add-to-list 'load-path "~/.emacs.d/flyspell")
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
(autoload 'flyspell-delay-command "flyspell" "Delay on command." t)
(autoload 'tex-mode-flyspell-verify "flyspell" "" t)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)  ; Auto-start flyspell with LaTeX


;;; Enable auto-complete mode
(require 'auto-complete)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(require 'auto-complete-config)
(ac-config-default)
(global-auto-revert-mode t)


;;; RefTex configuration
(require 'reftex)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(add-hook 'latex-mode-hook 'turn-on-reftex)


;;; Activate code folding in AUCTeX
(add-hook 'LaTeX-mode-hook (lambda ()
             (TeX-fold-mode 1)))


;;; Setup jedi
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)


;;; Pair braces and quotes automatically (autopair)
(require 'autopair)
(autopair-global-mode) ;; Enable autopair in all buffers


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

(require 'python)
(setq python-shell-interpreter "ipython")
(setq python-shell-interpreter-args "--pylab")

【问题讨论】:

    标签: python python-2.7 emacs ipython emacs24


    【解决方案1】:

    我对 python.el 代码不够熟悉,无法给你一个很好的答案,但是如果你看一下 python.el 的开头(“评论:”部分),你会发现它有点说话关于如何使用 Ipython。这就是说,它存在各种问题。即将发布的 24.4 中的 python.el 代码显着改进了对 Ipython 的支持,因此它不需要所有的配置并且实际上可以工作(据说)。由于 24.4 非常接近发布,我们正在寻找可以帮助我们摆脱最后几个错误的人,所以如果您可以尝试最新的预测试 (24.3.94) 看看是否能解决您的问题,那就太好了问题,如果没有,请发送M-x report-emacs-bug,以便我们在发布前修复它。

    【讨论】:

    • 我在 Windows 机器上。我可以吗?
    • 无论如何,当你告诉我在 python.el 中有一些关于 Ipython 的评论时。它对我有用。谢谢。
    【解决方案2】:

    我在 Windows 上使用 Emacs 24.3.1 时遇到了同样的问题,我所有的问题最终都通过将 ipython 进程硬塞到一个子进程中得到了解决(我从“评论”部分尝试了所有可能的方法,但无济于事 - 也许 Shaun 知道究竟是什么他改变了它?)。您在混合中获得了一个额外的 python 进程,但我在代码缓冲区和 python 缓冲区之间的控制方面没有任何问题。来自我的 .emacs:

    (setq
     python-shell-interpreter "C:\Python27\\python.exe"
     python-shell-interpreter-args "-u -c \"import subprocess; subprocess.call('ipython')\""
     python-shell-prompt-regexp "In \\[[0-9]+\\]: "
     python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
     python-shell-completion-setup-code
       "from IPython.core.completerlib import module_completion"
     python-shell-completion-module-string-code
       "';'.join(module_completion('''%s'''))\n"
     python-shell-completion-string-code
       "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多