Ask Your Question
0

init.sage doesn't work for the notebook server?

asked 2016-02-09 14:15:20 -0600

Eugene gravatar image

updated 2016-02-12 16:35:45 -0600

tmonteil gravatar image

Hello!

I have the same problem as in Is there a way to prefix all sage code in order to include a custom module?, but the init.sage appears not to work with notebook's worksheet. Here is what I have:

$ cat ~/.sage/init.sage 
import numpy as np

then inside Sage I have:

$ ./sage 
sage: np
<module 'numpy' from ....>

But then I run notebook() and create a new worksheet, inside that worksheet session:

np
NameError: name 'np' is not defined

So I assume that the script was not executed for the worksheet.

Is there a way to create sage.init but for the worksheets?

edit retag flag offensive close merge delete

Comments

P.S. I edited question to make it simpler. I that may be a bug?

Eugene gravatar imageEugene ( 2016-02-11 14:29:43 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-02-11 14:44:06 -0600

tmonteil gravatar image

updated 2016-02-11 14:51:59 -0600

I guess this is a bug, since the documentation do not restrict the use of init.sage to the command line. Thanks for reporting, it is now trac ticket 20042. Note that it works on the jupyter notebook, only the Sage notebook is affected.

A workaround could be to add the following line at the beginning of your worksheet:

import os ; load(os.environ['SAGE_STARTUP_FILE'])
edit flag offensive delete link more

Comments

Thank you! I suppose the question is answered and I should monitor track ticket from now on.

Eugene gravatar imageEugene ( 2016-02-13 15:09:27 -0600 )edit

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: 2016-02-09 14:15:20 -0600

Seen: 115 times

Last updated: Feb 11 '16