Some time ago, I asked this question, which is how to create new python shells that get renamed based on the script from which they are run, e.g., foo.py should create a shell *Python[foo.py]*, and foe.py creates *Python[foe.py]*. So far, that worked, but recently I needed to reinstall my OS, and hence Emacs. Now, when I try the same function, I get the error: NameError: name '__PYTHON_EL_eval_file' is not defined. It is the same error as as this question.
I hooked that function to C-c C-C. If I C-c C-c once the error is generated, but if I C-c C-c twice, then it works as expected. So, it seems by running C-c C-c once, the file is being generated.
This is the, according to my understanding, relevant code in my init.el file
(require 'python)
(use-package python-mode
:ensure t
:hook (python-mode . lsp-deferred)
:custom
(python-shell-interpreter "python"))
(use-package pyvenv
:config
(pyvenv-mode 1))
(setq python-shell-completion-native-enable nil)
(defun my-python-start-or-switch-rep (&optional msg)
"Start and/or switch to the REPL."
(interactive "p")
(if (python-shell-get-process)
(progn
(python-shell-send-buffer)
(python-shell-switch-to-shell)
)
(progn
(run-python (python-shell-calculate-command) t t)
(other-window 1)
(python-shell-send-buffer)
(python-shell-switch-to-shell)
)
)
)
(add-hook 'python-mode-hook
(lambda () (define-key python-mode-map (kbd "C-c C-c") 'my-python-start-or-switch-rep))
)
(put 'upcase-region 'disabled nil)
I searched the web, but didn't really find a solution; maybe the solution is simple. I am an Emacs noob, and most of my stuff is what I found online/asked and tried to change, so that's why I feel helpless. I'd appreciate any help.
M-x toggle-debug-on-errorand try again. Does it bring any new insights? (In that case add it to the question)*Messages*, and there was nothing there, or the ipython shell. I am not sure where else to search.*Backtrace*, however, that error is unrelated to this problem (the error was with lsp and completion). In other words,M-x toggle-debug-on-erroris working, but somehow my problem is not triggering anything.M-: (run-python (python-shell-calculate-command) t t), then switch back to your python buffer and doM-x python-shell-send-buffer?