Closed guibor closed 1 year ago
tagging @sunlin7 since he has recently contributed to python layer.
Hi @guibor
You mentioned the statement is in the function spacemacs//python-setup-shell
, which will try to setup the two variables:
python-shell-interpreter
and python-shell-interpreter-args
.
If you already got the correct value python-shell-interpreter
(as your comments, it's "ipython"), the function should skip to change the variables.
README.org explains that ipython
is default, when in reality the default is whatever (eval (car (get 'python-shell-interpreter 'standard-value)))
evaluates to. So either the code is incorrect or the documentation is.
Note that a few commits ago, the logic was as below (which indeed defaults to ipython
), and this changed for some reason:
(if (spacemacs/pyenv-executable-find "ipython")
(progn (setq python-shell-interpreter "ipython")
(if (version< (replace-regexp-in-string "\\(\\.dev\\)?[\r\n|\n]$" "" (shell-command-to-string (format "\"%s\" --version" (string-trim (spacemacs/pyenv-executable-find "ipython"))))) "5")
(setq python-shell-interpreter-args "-i")
(setq python-shell-interpreter-args "--simple-prompt -i")))
(progn
(setq python-shell-interpreter-args "-i")
(setq python-shell-interpreter "python")))
The follow commit/conversation has many details for how to determine the python shell interpreter. https://github.com/syl20bnr/spacemacs/pull/15848
The document says:
If =ipython= is available in system executable search paths, =ipython= will be used to launch python shell; otherwise, default =python= interpreter will be used. You may change your system executable search path by activating a virtual environment.
For your case, it seems you have local virtual environments ?
I do not have a local virtual environment.
What do you expect (eval (car (get 'python-shell-interpreter 'standard-value)))
to evaluate to?
That will give the standard value, which may be different from the customer value. Your initial comment says
python-shell-interpreter it is equal to "/opt/homebrew/bin/ipython"
That indicate it already get the ipython
, no need to manually change the value.
Or if the value is manually configured by user, then the spacemacs//python-setup-shell
won't change anything.
I did not change the value and it was not manually configured - indeed the the default should be ipython
.
This was the behavior in previous versions of this layer - but now it defaults to (eval (car (get 'python-shell-interpreter 'standard-value)))
which is just python3
.
standard-value of python-she'll-interpreter will be python3 or python and never ipython.
But the documentation (README.org
) says that ipython
is default.
Furthermore, this was the behavior in the past:
(defun spacemacs//python-setup-shell (&rest args)
(if (spacemacs/pyenv-executable-find "ipython")
(progn (setq python-shell-interpreter "ipython")
(if (version< (replace-regexp-in-string "\\(\\.dev\\)?[\r\n|\n]$" "" (shell-command-to-string (format "\"%s\" --version" (string-trim (spacemacs/pyenv-executable-find "ipython"))))) "5")
(setq python-shell-interpreter-args "-i")
(setq python-shell-interpreter-args "--simple-prompt -i")))
(progn
(setq python-shell-interpreter-args "-i")
(setq python-shell-interpreter "python"))))
I am describing a bug. I am not referring to documentation even for once.
Hi @guibor
Still unable get your key point. Do you have any suggestions on code change or document change? Then maybe can help me to understand what's your concern.
The documents said ipython in the path case:
If =ipython= is available in system executable search paths, =ipython= will be used to launch python shell; otherwise, default =python= interpreter will be used. You may change your system executable search path by activating a virtual environment.
See also #15873. I think my diagnosis is accurate:
I use conda, but I believe the issue is somewhere in the commit; reverting to
b28d65b7a
,python-shell-interpreter
becomes "ipython", but usingb28d65b7a
(orHEAD
), it has the value "python3". I also verified that the same behavior occurs when not using conda (removing the entire anaconda subtree from PATH) and on a fresh install of spacemacs.
trying to reproduce on my local now.
@guibor please help verify the solution #16011 , thanks
Thanks this fixes the issue for me!
Thanks, merged.
Description :octocat:
In README.org, it is indicated that "ipython" is the default interpreter for the python shell: "If ipython is available in system executable search paths, ipython will be used to launch python shell".
When I check the value of
python-shell-interpreter
it is equal to "/opt/homebrew/bin/ipython" andspacemacs--python-shell-interpreter-origin
is equal to "python3" ((eval (car (get 'python-shell-interpreter 'standard-value)))
evaluates to "python3"). As a result,(or (null python-shell-interpreter) (equal python-shell-interpreter spacemacs--python-shell-interpreter-origin))
isnil
and the entire environment isn't setup correctly unless I manually setpython-shell-interpreter
to "ipython".Reproduction guide :beetle:
spacemacs/python-start-or-switch-repl
Observed behaviour: :eyes: :broken_heart:
python3
shell is launched unlesspython-shell-interpreter
is manually set to "ipython"Expected behaviour: :heart: :smile:
ipython
shell starts.System Info :computer: