I would expect magic commands to work a little differently in the jupyter
gui than on the command line, so the possibility for an error doesn't
surprise me too much. It can probably be fixed. However, a straight-up
"attach('<file here>')" would hopefully work? It still needs to hook into
the REPL to actually check for a changed file and do the reloading, but
that has a better chance of being the same between the IPython CLI shell
and the Jupyter notebook.
On Wednesday, December 12, 2018 at 9:15:46 AM UTC-8, John Cremona wrote:
>
> I have a file testcong.py which contains various functions I am
> developing, while testing them in a jupyter notebook. The first cell in
> the notebook has the "magic" line "%run testcong.py" and so whenever I make
> a change to the .py file I have to re-click on that cell. This gets
> tedious, especially when the testing notebook has may cells in it since I
> am forever scrolling up and down.
>
> There has to be a better way. From the command line one can use attach
> instead of runfile (which automatically rereads the file when it changes)
> but I cannot get that to work, even though there is a magic %attach command:
>
> %attach testcong.py
>
> fails with a weird error message which is incomprehensible to me:
>
> "UsageError: Invalid GUI request 'sage', valid ones are:['osx', 'widget',
> 'qt5', None, 'qt', 'nbagg', 'gtk', 'qt4', 'gtk3', 'notebook', 'tk',
> 'ipympl', 'inline', 'asyncio', 'wx']"
>
> while
>
> %attach "testcong.py"
>
> (with quotes) is better, it just cannot find the file (which is in the
> current directory, i.e. the one I started the notebook from). But giving
> the full pathname
>
> %attach "/home/jec/congruences/testcong.py"
>
> also gives "IOError: did not find file
> '/home/jec/congruences/testcong.py"' to load or attach"
>
> What am I doing wrong? I did try looking for documentation but failed...
>
>
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.