Ask Your Question
1

%attach/attach() does not work in sage jupyter (sage 7.5.1)

asked 2017-01-23 13:37:18 +0200

notabot gravatar image

Whenever I open a jupyter notebook in Sage 7.5.1 (sage -n jupyter), issuing a magic command

%attach myfile.py

or an inline attachcommand

attach("muyfile.py")

results in an error:

UsageError: Invalid GUI request 'sage', valid ones are:['osx', 'qt4', 'qt5', 'nbagg', None, 'gtk', 'gtk3', 'notebook', 'tk', 'inline', 'wx', 'qt']

I found this error in sagemath 7.5.1, but it is not present in sagemath 7.2. The magic %load, however, works.

Any workarounds? (besides changing %attach to %load, I mean.)

edit retag flag offensive close merge delete

Comments

1

Upon further searching, I found that in file /Applications/SageMath-7.5.1.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/repl/inputhook.py there is a registered input hook: register('sage', sage_inputhook). It seems that the 'sage' GUI has no support for attaching files?

notabot gravatar imagenotabot ( 2017-01-23 14:41:22 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-01-24 12:05:29 +0200

notabot gravatar image

Since the answer is “Any workarounds?”, I'll document the one workaround that I found. However, the original problem persists; so I think that a bug report is due.

The workaround is to replace

%attach file.py

with

load("file.py")

Note that this workaround looses the automatic reloading feature; which is the point of attach in the first place. But at the very least, I can now load code and data from files.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-01-23 13:32:59 +0200

Seen: 315 times

Last updated: Jan 24 '17