简体   繁体   中英

Why does the python interpreter not print input code and output in emacs python shell buffer for python-mode?

My current python setup in emacs is:

(setq py-shell-name "ipython") ;; sudo pip install ipython
(setq py-shell-name "/usr/local/bin/ipython")
(setq py-force-py-shell-name-p t)
(add-to-list 'load-path "~/.emacs.d/python-mode.el-6.1.0/") 
(setq py-install-directory "~/.emacs.d/python-mode.el-6.1.0/")
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))

In a python file, I start the python interpreter with "Cc !" (py-shell). I evaluate region of codes with "Cc |" (py-execute-region).

If I execute each of the following line individually,

x = "hello world"
x
print(x)

I get the following in the python shell buffer:

Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: 
In [5]: 
In [6]: hello world

In [7]: 

If I use the default python interpreter, I get

Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> >>> >>> hello world
>>> 

Questions:

  1. Are these behaviour correct (not showing which code is being evaluated, and not showing what a python interpreter would normally print)?

  2. How do I set it so that the python shell prints output like a normal python interpreter in the terminal? (with input code and output printed)

I guess I'm used to ESS for R. Thanks.

Your are looking for feature, which might be implemented.

In cases like this, please file this as question at

https://answers.launchpad.net/python-mode

When done, use at bottom "(+) Create bug report".

It creates a ticket, which helps us to track the issue.

Alternatively you may create a Blueprint and link a ticket afterwards.

Done so far:

https://blueprints.launchpad.net/python-mode/+spec/print-input-code

Beside, your init displays some useless code - however not harmful. Second setting of "py-shell-name" takes the symbol of the first one.

"...-mode-alist" stuff is already done from python-mode, you must not care for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM