I have started to use Spacemacs to edit python files and also to use org-mode, but now I want to run python from Spacemacs instead of running Anaconda Prompt.
I've written this in .spacemacs
file with SPC f e d
:
(defun dotspacemacs/user-init ()
"Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
(setq python-shell-interpreter "C:/Users/Mahesvara/Documents/Personal_Documents/Programs/Anaconda3/python.exe")
)
But when I try to run the script with C-c C-p
it gives the following error: Searching for program: No such file or directory, python
I am not entirely familiar with Spacemacs on Windows, but here is my go at this...
Note that anaconda prompt is not a shell, it is an command prompt interface to anaconda (see here).
Windows uses cmd. Spacemacs, Unix, and Python use shells, and are a completely different interface.
What you put in that variable shouldn't be a file path. It should be a name of a program.
Emacs has a list of places where executable are stored.
This variable is called exec-path
.
Here is how to set it.
I would recommend not modifying it, but viewing it
(print exec-path)
There then needs to be a python shell in one of those paths (i.e. python, ipython, etc.).
A more experienced Windows developer may want to disagree with this. But it may be helpful to install some Babun/Cygwin shell to install python with. Especially if you are using Spacemacs. This would allow you to run in a more Unix-y environment which works better for Spacemacs. Just make sure the home directories match up.
Once you have a python shell program installed in one of the exec-path
's,
You should be able to:
(setq python-shell-interpreter "python")
Change python to whatever python shell you chose.