1

Emacs: How do I detect which Python mode is running and select default Python interpreter?

First of all, how do I see which Python mode is running?

I've read that multiple exist, like python-mode.el etc.

Secondly, pressing C-c C-z results in a Run Python dialog appearing. I use Python3 and I want this to be the default. So, instead of always editing python to python3 in the path /usr/bin/python -i, how do I make this automatically?

Please resond so a newbie to Emacs can understand the details :-)

enter image description here

2 Answers 2

1

First off lets start off by finding out which python mode you're using. Generally unless you downloaded something and actively decided to use python-mode.el you won't be using it, instead you'll be using the great, built-in, python.el. If you didn't know this you could press C-h m to bring up the help menu for the mode that you're currently in. A bit down the page you'll notice that it says "Python mode is defined in 'python.el'". Neat!

Okay so choosing the interpreter is pretty easy. There is a variable called python-shell-interpreter you can set this variable to anything you want! For example you can set it to "python3", I personally have it set to "ipython". The code to place in your init file, is (setq python-shell-interpreter "python3")

If you have any other questions feel free to let me know!

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer. What exactly is "ipython", and why don't I use this by default?
Ipython lets you interact with python the same way that the normal interpretter does, I just think it looks prettier
0

In your init file you can place the following:

(setq python-shell-interpreter "/usr/bin/python3")

so that Emacs will use Python 3 instead of Python 2. Here's info on init files in case you don't know about them.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.