【问题标题】:How can I run IPython within Emacs under Cygwin for my Enthought Python Distrubution installation?如何在 Cygwin 下的 Emacs 中为我的 Enthought Python Distrubution 安装运行 IPython?
【发布时间】:2014-05-06 17:51:17
【问题描述】:

我喜欢 Emacs,但我无法使用 Windows 7。我已经安装了 Cygwin,并且可以使用 Emacs 来完成基本的编辑任务。我可以将 Emacs 设置为运行 IPython 的 Cygwin 安装,但我宁愿运行 IPython 的 Enthought Python Distribution 版本。

根据here 的建议,我将以下内容添加到我的~/.emacs 文件中:

(when (executable-find "ipython")
  (setq
   python-shell-interpreter "/cygdrive/c/Python27/Scripts/ipython.bat"
   python-shell-interpreter-args ""
   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"))

注意我修改了第三行指向ipython.bat。然后我启动了解释器,它加载了 EPD,但是我得到了以下错误并且不能做任何事情:

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
C:\Users\username\My Documents\python\<ipython-input-2-6552ae2ca310> in <module>()
----> 1 __pyfile = open('''/tmp/py6644bAS''');exec(compile(__pyfile.read(), '''/tmp/py6644bAS''', 'exec'));__pyfile.close()

IOError: [Errno 2] No such file or directory: '/tmp/py6644bAS'
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
C:\Users\username\My Documents\python\<ipython-input-3-492fce3681b4> in <module>()
----> 1 __pyfile = open('''/tmp/py6644XOK''');exec(compile(__pyfile.read(), '''/tmp/py6644XOK''', 'exec'));__pyfile.close()

IOError: [Errno 2] No such file or directory: '/tmp/py6644XOK'

有什么想法或其他方法可以让我通过 Cygwin 在 Emacs 中运行 EPD 的 IPython 安装吗?

【问题讨论】:

    标签: emacs cygwin ipython enthought


    【解决方案1】:

    这是一种如何调整 python-mode.el 与 Anaconda 一起使用的方法 - 不完全是您想要的,但它可能会提供一些提示:

    (defun ipython (&optional argprompt)
      "Start an IPython interpreter.
    
    Optional \\[universal-argument] prompts for options to pass to the IPython interpreter. See `py-python-command-args'. "
      (interactive "P")
      (setq py-ipython-command "C:\\Users\\MYNAME\\Anaconda\\Scripts\\ipython.exe")
      (py-shell argprompt nil py-ipython-command))
    

    【讨论】:

    • 这在一定程度上确实有帮助:我还安装了 Enthought Canopy,它有一个 ipython.exe 脚本而不是 ipython.bat。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-19
    • 2014-11-26
    相关资源
    最近更新 更多