I'm running IPython in an emacs shell using:
;; Set IPython interpreter in my init.el
(defvar python-shell-interpreter "ipython")
(defvar python-shell-interpreter-args "-i")
Then:
- Start IPython with
M-x run-python
- Run a program within IPython with
%run myprog.py
. myprog.py imports a module calledmymodule
.
I make changes to mymodule
but when I run %run myprog.py
again, it runs the original mymodule
, not the changed code.
FWIW, I'm using emacs 24.5 prelude, on Windows 10 with Anaconda and Python 3.5.
It turns out that IPython's
%run
command does not reload modules.My current workaround is:
~/.ipython/profile_default/ipython_config.py
$run myprog.py args
.
I didn't realise that
%run
does not reload modules because I'm used to using Spyder'srunfile
command, which does. It's nuts that%run
doesn't and I'd like to submit a patch to fix it at some point.On Windows, the HOME environment variable must be set so that the
run-python
command inemacs
can read the IPython profile. If HOME is not set, you can add this to yourinit.el
: