Emacs次pythonshellsendregion命令显示发送消息

2024-09-26 22:13:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我在OS X(El Capitan)上使用Python次shell,每次向Python进程发送一段代码(使用绑定到python-shell-send-region)的C-c C-r),我都会在Python shell中收到如下消息:

>>> import codecs, os;
    __pyfile = codecs.open('''/var/folders/6j/g9hcs1s17g1dgxr3p_m04rq80000gn/T/py5013kfY''', encoding='''utf-8''');
    __code = __pyfile.read().encode('''utf-8''');
    __pyfile.close();
    os.remove('''/var/folders/6j/g9hcs1s17g1dgxr3p_m04rq80000gn/T/py5013kfY''');
    exec(compile(__code, '''/Users/user/Desktop/sample.py''', 'exec'));

我不希望每次调用命令时都显示此消息。Linux上相同版本的Emacs(与Python.el文件)没有这个问题。消息的模板是在python-shell-send-file函数中定义的(在python.el文件中),这本身就很令人费解,因为我无法看到当我调用python-shell-send-region时如何调用这个函数。对于第一次运行,我使用以下命令调用Python解释器(版本2.7.10)

^{pr2}$

但它的行为与其他python解释器(通过brew安装)的行为相同。我使用的是Emacs24.5.1(再次通过brew安装)。我在.emacs中使用的唯一特定于python模式的配置与选项卡宽度有关:

(add-hook 'python-mode-hook
      (lambda ()
        (setq indent-tabs-mode t)
        (setq tab-width 2)
        (setq python-indent 2)))

如有任何帮助或建议,我们将不胜感激。在

编辑和可能的解决方案

(我找到了这个https://github.com/jorgenschaefer/elpy/issues/1307):

$ easy_install-3.6 gnureadline
$ cd /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
$ mv readline.cpython-36m-darwin.so readline.cpython-36m-darwin.so.bak

如果在安装gnureadline fatal error: 'stdio.h' file not found时出错,请尝试xcode-select --install。在


Tags: send消息osvarcodeshellregionutf

热门问题