necaris / conda.el

Emacs helper library (and minor mode) to work with conda environments
MIT License
153 stars 49 forks source link

When python-shell-interpreter is set to "jupyter", conda is unable to change the environment of the interpreter. #135

Open zhenhua-wang opened 1 year ago

zhenhua-wang commented 1 year ago

Hi,

conda.el works very well when python-shell-interpreter is set to "python3". However, when using "jupyter" as python-shell-interpreter , the jupyter console is still executed in the base environment even if I have called conda-env-activate.

Below are my configs for python shell interpreter

(setq python-shell-interpreter "jupyter"
      python-shell-interpreter-args "console --simple-prompt"
      python-shell-prompt-detect-failure-warning nil)
(add-to-list 'python-shell-completion-native-disabled-interpreters
             "jupyter")
necaris commented 1 year ago

Can you show me the output of which -a jupyter in your terminal?

Zhenhua Wang @.***> writes:

Hi,

conda.el works very well when python-shell-interpreter is set to "python3". However, when using "jupyter" as python-shell-interpreter , the jupyter console is still executed in the base environment even if I have called conda-env-activate.

Below are my configs for python shell interpreter

(setq python-shell-interpreter "jupyter" python-shell-interpreter-args "console --simple-prompt" python-shell-prompt-detect-failure-warning nil) (add-to-list 'python-shell-completion-native-disabled-interpreters "jupyter")

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

-- Rami Chowdhury A mind all logic is like a knife all blade - it makes the hand bleed that uses it. -- Rabindranath Tagore

zhenhua-wang commented 1 year ago

Thanks for your reply. Before conda activate, which -a jupyter gives

Screenshot_20221106_122501

After running conda activate tf, the jupyter in the tf does show up

Screenshot_20221106_122413

necaris commented 1 year ago

I suspect you want to use the pythonic helper functions for your use-case -- as suggested at https://github.com/pythonic-emacs/pythonic#project-settings , if you set the pythonic-interpreter variable it may behave better:

(setq pythonic-interpreter "jupyter")

Note that conda.el changes the Python environment using python-shell-virtualenv-root, which is provided by python.el in the core Emacs distribution, and I'm not 100% sure how to make sure jupyter's path is correctly calculated.

If this doesn't work for you, please reopen and we can figure out how to do this!

zhenhua-wang commented 1 year ago

Thanks for your help! The variable python-shell-interpreter is also part of the core emacs, so I also have no idea why this won't work. As for the pythonic package, I am not sure what it does as oppose to core emacs, so I don't plan to use it.

I do find that Ipython console ((setq python-shell-interpreter "ipython")) works very well with conda.el. Since ipython is almost the same as jupyter, I'll just use this console.