Is there a way to force a new instance of python-shell
while running Emacs? It would be convenient when working on multiple projects with separate working directories (and different sets of modules).
Any attempt to invoke python-shell
will only pull up the current instance.
Renaming the buffer doesn't work for me, but you can use the third parameter of
run-python
.M - :
(run-python nil nil t)
RETSince the binding to switch to the current buffer isn't really helpful you can rebound it to something more useful
And use C-cC-z to switch to the current python interpreter and C-uC-cC-z to switch to a fresh python interpreter.
You need to rename your original python-shell before opening up a new one. Use M-x
rename-buffer
.When using
python-mode
via python.el, having one Python shell per Python buffer is the default.However, you can change this default behavior if what you want instead is for multiple Python buffers to share the same Python shell. To do so, after opening the first Python buffer, enter:
...which is documented:
Then later, if you want a new Python buffer to use its own shell, enter:
After doing so and then opening a new Python buffer, a new Python shell will be created for that buffer after entering
python-switch-to-python
orC-c C-z
.