【问题标题】:Can't get python-mode working in Emacs on Mac OS X无法在 Mac OS X 上的 Emacs 中使用 python 模式
【发布时间】:2012-06-14 06:57:44
【问题描述】:

我无法在 Mac OS X 上的 Emacs 中使用 python 模式(我是相对的 OS X 新手,不完全是 Elisp 专家)。

我从http://emacsformacosx.com/ 安装了 Emacs。该版本报告为“bob.porkrind.org 上 2011-12-13 的 GNU Emacs 23.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)”

我的~/.emacs 文件中有以下几行:

(add-to-list 'load-path "/Applications/Emacs.app/Contents/Resources/lisp/progmodes")
(setq auto-mode-alist
      (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
      (cons '("python" . python-mode) interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python Editing Mode" t)

但每当我加载扩展名为.py 的文件时,模式仍然保持Fundamental

【问题讨论】:

    标签: python macos emacs


    【解决方案1】:

    尝试在您的 python-lisp-includes 代码之前将其添加到您的 .emacs 文件中(另外,设置您的 python-mode 的路径。我的位于 .emacs.d/ 文件夹中)

    (add-to-list 'load-path "~/.emacs.d/python-mode")
    (require 'python-mode)
    

    在此处查找文件 http://www.emacswiki.org/emacs/?action=browse;oldid=PythonMode;id=PythonProgrammingInEmacs

    【讨论】:

    • 我的~/.emacs.d/ 目录中没有python-mode.(el|elc)
    • @markvgti 你可以在互联网上寻找它。更新了答案。
    【解决方案2】:

    好的,这就是我在安装时使用 python 模式(python-mode.el,而不是 python.elc)的方法:

    1. 已将python-mode.el-6.0.8.tar.gz 下载到我的~/Downloads 文件夹。
    2. pushd /Emacs/directory/with/other/.el/files(这个目录实际上是我机器上的/Applications/Emacs.app/Contents/Resources/lisp/progmodes/
    3. tar -xzf ~/Downloads/python-mode.el-6.0.8.tar.gz
    4. popd
    5. 然后将以下行添加到我的 ~/.emacs 文件中(替换所有其他对 python 或 python-mode 的引用):

      (add-to-list 'load-path "/Emacs/directory/with/other/.el/files/python-mode.el-6.0.8")
      (setq py-install-directory "/Emacs/directory/with/other/.el/files/python-mode.el-6.0.8")
      (require 'python-mode)
      

    现在唯一剩下的问题(由成功安装和激活 python-mode 造成)是通过 Python 解释器的交互式调用也创建了不必要的缓冲区。

    感谢@Ribtoks 提供的链接让我开始走上正确的道路。

    【讨论】:

      【解决方案3】:

      如果你的加载路径是正确的,你能试着在它后面加上这行吗?

      (autoload 'python-mode "python-mode" "Python Mode." t)
      

      我正在使用 Linux 的 emacs。不知道这是否可能与 Aquamacs 不同。 无论如何,有一个page 用于使用 Python 模式配置 Aquamacs。 没读过,但也许它应该值得一读以获取任何相关提示.. :)

      【讨论】:

      • 没用。获取文件模式指定错误:(file-error "Cannot open load file" "python-mode") 前面提到的路径中有python.elc (/Applications/Emacs.app/Contents/Resources/lisp/progmodes)
      • 使用'load-path 添加的路径必须指向实际的.el|.elc 文件,还是只指向包含相关.el|.elc 文件的目录?
      • 它应该指向文件。对我来说,它的工作方式是这样的,直接加载文件......(加载“~/.emacs.d/py_mode/6.0.6python-mode.el”)(参见答案的编辑)
      【解决方案4】:

      python-shell 实例的自动创建应该在当前主干中修复,分别。最新版本

      如果没有,请提交报告至 https://bugs.launchpad.net/python-mode

      【讨论】:

        猜你喜欢
        • 2014-08-05
        • 2011-06-15
        • 1970-01-01
        • 1970-01-01
        • 2013-10-31
        • 2016-07-26
        • 2011-03-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多