R.30
R.30

Reputation: 67

Emacs doesn't start python interpreter

I've recently installed Debian Linux 11 on my PC and on this Python 3.9 and Emacs 27.1 with the tools provided with Linux. I wrote a small Fibonacci test file on Emacs. Emacs shows the python menu, formats the code, makes correct auto-indent --> everything's fine. I saved the file and wanted to invoke the Python interpreter C-c C-p, but Emacs didn't find python.

I found out that Python couldn't be started from the shell too. I solved this by editing the local shell script .bashrc with the alias

alias python='/usr/bin/python3.9'

Testing with python --version responds with the version-No, and everything works fine, however emacs doesn't find python either. Doing the same by starting from the Emacs shell (M-x shell) works too, but C-c C-p doesn't still work.

I can't find out, if it's a problem of DEBIAN or of Emacs. It seems that either the synaptic package manager installs programs without configuring completely or there is a bug in the Emacs configuration.

I have the same configuration on a laptop with Win10 and there Emacs works fine Python.

I'm a newbee on Linux and Emacs and hope to get a solution, where I don't need to get too deep into internals.

To be honest, I'm a little bit disappointed, that simple things don't run here.

Upvotes: 0

Views: 824

Answers (1)

R.30
R.30

Reputation: 67

OK, now I put the follwing line into the *scratch*-buffer and evaluted this:

(setq python-shell-interpreter "python3.9")

Also possible to reduce that to

(setq python-shell-interpreter "python3")

C-c C-p invokes now the python shell which reacts on evaluating the python code.

Next step I created in the folder ~/.emacs.d the file init.el and put this line in. Starting Emacs works now. When invoking the python shell, I see that Emacs starts a script called python.el. Perhaps this should be corrected, but I can't find it.

For me it fits now, but that means that Emacs doesn't take any aliases from the OS but must be configured separately - at least when using Linux, because with Win10 it's obviously not necessary to set this variable.

Upvotes: 1

Related Questions