Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs Inferior Python shell shows the send message with each python-shell-send-region command

I am using the Python inferior shell on OS X (El Capitan) and every time I send a piece of code to the Python process (using C-c C-r which is bound to python-shell-send-region) I get a message like this in the 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')); 

I would like to not have this message shown with each invocation of the command. The same version of Emacs on Linux (together with python.el file) does not have this problem. The template of the message is defined in python-shell-send-file function (in python.el file), which in itself is puzzling as I cannot see how this function is called when I invoke python-shell-send-region. For the first run I invoke the Python interpreter (version 2.7.10) with the following command

/usr/bin/python -i 

but it also behaves the same with other python interpreters (installed via brew). I am using Emacs 24.5.1 (again installed via brew). The only python-mode specific configuration I use in .emacs are related to the tab width:

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

Any help or suggestion is appreciated.

Edit and a possible solution:

(I found this 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 

If you get an error while installing gnureadline, fatal error: 'stdio.h' file not found, try xcode-select --install.

like image 804
s.yadegari Avatar asked Nov 15 '15 23:11

s.yadegari


1 Answers

$ source ./your/venv/activate $ pip install pyreadline 

Should work automatically with Python. I experienced a similar issue on Windows 10 earlier this year, installing pyreadline as a dev dependency resolved it.

like image 145
skullgoblet1089 Avatar answered Sep 24 '22 21:09

skullgoblet1089