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
.
$ 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With