Reputation: 13860
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 :-)
Upvotes: 1
Views: 908
Reputation: 1
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.
Upvotes: 0
Reputation: 973
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!
Upvotes: 1