python interpreter fails to start

Asked by bootboy

Hi,

I started using python-mode 6.1.3 on centos 6. By running command M-x python2.7 to launch the python interpreter, I got the following error shown in buffer *python2.7*.

Process python2.7 exited abnormally with code 2
Unknown option: --
usage: /usr/local/bin/python2.7 [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

By running command M-x py-shell, I am able to get a working buffer *ipython* running python 2.7. However, when I try to run py-execute-region on a selected python code snippet, the command doesn't send the region to the ipython buffer. Instead, I got a buffer *python* with the following error message.

Process python exited abnormally with code 2
Unknown option: --
usage: /home/me/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

Process python exited abnormally with code 2

/home/me/bin/python is a symbolic link I created to for /usr/local/bin/python2.7.

Please advise.

thanks

Question information

Language:
English Edit question
Status:
Answered
For:
python-mode.el Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
Andreas Roehler (a-roehler) said :
#1

On 28.06.2014 17:31, bootboy wrote:
> New question #250905 on python-mode.el:
> https://answers.launchpad.net/python-mode/+question/250905
>
> Hi,
>
> I started using python-mode 6.1.3 on centos 6. By running command M-x python2.7 to launch the python interpreter, I got the following error shown in buffer *python2.7*.
>
> Process python2.7 exited abnormally with code 2
> Unknown option: --
> usage: /usr/local/bin/python2.7 [option] ... [-c cmd | -m mod | file | -] [arg] ...
> Try `python -h' for more information.
>
>

Try editing the python2.7 command by filling in the complete path, see screenshot attached.
BTW screenshot display is from current trunk, where python-versioned commands are only provided WRT python2 or 3.
You may specify as many commands as you like, just give the PATH/TO/EXEcutable

There are aspects WRT pythonpath, which can't be dealt with here.

If it still doesn't work, please try with current trunk. Should this fail too, please file a bug-report.

Revision history for this message
bootboy (bootboy999) said :
#2

Andreas,

I tested your suggestions using the current trunk. The original problem is sovled. But I got a different problem.

Here is the python-mode setting in my .emacs

(setq py-install-directory "~/.emacs.d/python-mode")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)
(when (featurep 'python) (unload-feature 'python t))

(setq py-shell-name "/usr/local/bin/ipython")
(setq py-ipython-command "/usr/local/bin/ipython")
(setq py-python-command "/usr/local/bin/python2.7")

With menu python > Interpreter > Default interpreter, I got a *python* buffer with python 2.7 running inside. This is good.

However, with menu python > Interpreter > Other > ipython, I got a *ub IPython* buffer with the following error message
Can't exec program: /usr/bin/ipython
Process /usr/bin/ipython exited abnormally with code 1

I wonder how to get ipython as the default interpreter. It seems python-mode still uses /usr/bin/ipython as the default ipython path, instead /usr/local/bin/ipython, the one I set in .emacs.

BTW, could you post your screen shot again? It seems neither attached in the email nor displayed in the question webpage .

thanks

Revision history for this message
Andreas Roehler (a-roehler) said :
#3

Use setq-default instead of setq - this are buffer-local variables. Setq will only affect the current buffer.
I'll create a bug-report for this, as attachments seem not to pass here, but will arrive at the ticket.

Revision history for this message
Andreas Roehler (a-roehler) said :
#4

On 29.06.2014 17:21, bootboy wrote:
> Question #250905 on python-mode.el changed:
> https://answers.launchpad.net/python-mode/+question/250905
>
> Status: Answered => Open
>
> bootboy is still having a problem:
> Andreas,
>
> I tested your suggestions using the current trunk. The original problem
> is sovled. But I got a different problem.
>
> Here is the python-mode setting in my .emacs
>
> (setq py-install-directory "~/.emacs.d/python-mode")
> (add-to-list 'load-path py-install-directory)
> (require 'python-mode)
> (when (featurep 'python) (unload-feature 'python t))
>
> (setq py-shell-name "/usr/local/bin/ipython")
> (setq py-ipython-command "/usr/local/bin/ipython")
> (setq py-python-command "/usr/local/bin/python2.7")
>
> With menu python > Interpreter > Default interpreter, I got a *python*
> buffer with python 2.7 running inside. This is good.
>
> However, with menu python > Interpreter > Other > ipython, I got a *ub IPython* buffer with the following error message
> Can't exec program: /usr/bin/ipython
> Process /usr/bin/ipython exited abnormally with code 1
>
> I wonder how to get ipython as the default interpreter. It seems python-
> mode still uses /usr/bin/ipython as the default ipython path, instead
> /usr/local/bin/ipython, the one I set in .emacs.
>

Should this not be gone after using setq-default instead of setq - see other answer, correct customization.

M-x customize-variable RET py-ipython-command RET

then insert either just ipython, expected to be in $PATH, or full path /usr/local/....

This is also a bug BTW, as no path should be given in default.

Revision history for this message
bootboy (bootboy999) said :
#5

Andreas,

Thanks for your reply.

I now use setq-default instead of setq in .emacs. I am able to launch my ipython now. So the problem is solved.
(setq-default py-shell-name "/usr/local/bin/ipython")
(setq-default py-ipython-command "/usr/local/bin/ipython")
(setq-default py-python-command "/usr/local/bin/ipython").

Sorry to bother you again. Here is a new problem. I have my emacs frame split into two buffers -- left buffer for a python script and right buffer for the ipython session. When I run Python > Execute Region, the frame is split into three buffers, with the top buffer and the bottom left buffer for the script and the bottom right buffer for the ipython session. This auto split of frame is distracting. Can you suggest how to prevent it from happening?

thanks

Revision history for this message
bootboy (bootboy999) said :
#6

Thanks Andreas Roehler, that solved my question.

Revision history for this message
Andreas Roehler (a-roehler) said :
#7

On 02.07.2014 03:12, bootboy wrote:
> Question #250905 on python-mode.el changed:
> https://answers.launchpad.net/python-mode/+question/250905
>
> Status: Answered => Solved
>
> bootboy confirmed that the question is solved:
> Andreas,
>
> Thanks for your reply.
>
> I now use setq-default instead of setq in .emacs. I am able to launch my ipython now. So the problem is solved.
> (setq-default py-shell-name "/usr/local/bin/ipython")
> (setq-default py-ipython-command "/usr/local/bin/ipython")
> (setq-default py-python-command "/usr/local/bin/ipython").
>
> Sorry to bother you again. Here is a new problem. I have my emacs frame
> split into two buffers -- left buffer for a python script and right
> buffer for the ipython session. When I run Python > Execute Region, the
> frame is split into three buffers, with the top buffer and the bottom
> left buffer for the script and the bottom right buffer for the ipython
> session. This auto split of frame is distracting. Can you suggest how
> to prevent it from happening?
>
> thanks
>

Customize `py-keep-windows-configuration'. WRT current session, you may toggle it via menu
Python/Customize/Switches/Display

Revision history for this message
Andreas Roehler (a-roehler) said :
#8

On 02.07.2014 03:12, bootboy wrote:
> Question #250905 on python-mode.el changed:
> https://answers.launchpad.net/python-mode/+question/250905
>
> Status: Answered => Solved
>
> bootboy confirmed that the question is solved:
> Andreas,
>
> Thanks for your reply.
>
> I now use setq-default instead of setq in .emacs. I am able to launch my ipython now. So the problem is solved.
> (setq-default py-shell-name "/usr/local/bin/ipython")
> (setq-default py-ipython-command "/usr/local/bin/ipython")
> (setq-default py-python-command "/usr/local/bin/ipython").
>

Great it works now. Nonetheless, removed that buffer-local spec in trunk, so a simple `setq' should work now.
After all, requiring setq-default seems too costly WRT to possible gains.

Revision history for this message
bootboy (bootboy999) said :
#9

Hi Andreas,

I goggled it via menu Python/Customize/Switches/Display. It solved my problem.

I have two related questions.

Do I still need to put (require 'ipython) in .emacs? It seems this statement gives me the following error on on start up with the latest python-mode.

Debugger entered--Lisp error: (void-variable py-shell-map)
  (define-key py-shell-map (kbd "RET") (quote ipython-send-and-indent))
  eval-buffer(#<buffer *load*-456685> nil "~/.emacs.d/ipython.el" nil t) ; Reading at buffer position 21751
  load-with-code-conversion("~/.emacs.d/ipython.el" "~/.emacs.d/ipython.el" nil t)
  require(ipython)
  eval-buffer(#<buffer *load*> nil "~/.emacs" nil t) ; Reading at buffer position 29884

The other question is that with python-mode 5.x.0 I got the following header when I started ipython.
Python 2.7.5 (default, Sep 26 2013, 21:58:22)
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- 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.

With the latest python-mode, I got the followings without the python/ipython version information when starting ipython. Wonder how to get the version information displayed in the lastest python-mode. Note I don't have (require 'ipython) in .emacs using the latest python-mode while I have (require 'ipython) in .emacs using prior version of python-mode.

In [1]:
In [2]:
In [3]:

thanks

Revision history for this message
Andreas Roehler (a-roehler) said :
#10

On 03.07.2014 02:26, bootboy wrote:
> Question #250905 on python-mode.el changed:
> https://answers.launchpad.net/python-mode/+question/250905
>
> Status: Solved => Open
>
> bootboy is still having a problem:
> Hi Andreas,
>
> I goggled it via menu Python/Customize/Switches/Display. It solved my
> problem.
>
> I have two related questions.
>
> Do I still need to put (require 'ipython) in .emacs?

No

  It seems this
> statement gives me the following error on on start up with the latest
> python-mode.
>
> Debugger entered--Lisp error: (void-variable py-shell-map)
> (define-key py-shell-map (kbd "RET") (quote ipython-send-and-indent))
> eval-buffer(#<buffer *load*-456685> nil "~/.emacs.d/ipython.el" nil t) ; Reading at buffer position 21751
> load-with-code-conversion("~/.emacs.d/ipython.el" "~/.emacs.d/ipython.el" nil t)
> require(ipython)
> eval-buffer(#<buffer *load*> nil "~/.emacs" nil t) ; Reading at buffer position 29884
>
>

Normally python-mode.el would protect against this by delivering a defvaralias

Seems lp:912919 resp. 912919 came back.

Writing

(defvaralias 'py-mode-map 'python-mode-map)

at top of your ipython.el should silence that.

> The other question is that with python-mode 5.x.0 I got the following header when I started ipython.
> Python 2.7.5 (default, Sep 26 2013, 21:58:22)
> Type "copyright", "credits" or "license" for more information.
>
> IPython 1.1.0 -- 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.
>
> With the latest python-mode, I got the followings without the
> python/ipython version information when starting ipython. Wonder how
> to get the version information displayed in the lastest python-mode.

Seems something wrong with the command args. A bug-report for this might be helpful.

> Note I don't have (require 'ipython) in .emacs using the latest python-
> mode while I have (require 'ipython) in .emacs using prior version of
> python-mode.
>
>
> In [1]:
> In [2]:
> In [3]:
>
>
> thanks
>

Can you help with this problem?

Provide an answer of your own, or ask bootboy for more information if necessary.

To post a message you must log in.