Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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 sys
import os
import numpy as np

dev_path = os.path.join(os.path.expanduser("~"), 'Development')                                                                                       
if dev_path not in sys.path:                                                                                                                          
    sys.path.append(dev_path)

$ ~/Downloads/sage-6.10-Ubuntu_15.10-x86_64/sage 
RecursionError: maximum recursion depth exceeded during compilation                                                                                   
┌────────────────────────────────────────────────────────────────────┐
│ SageMath Version 6.10, Release Date: 2015-12-18                    │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: sys.path
sage: sys.path[-1:]
['/home/eugene/Development']

But then I run notebook(), create a new worksheet and the sys.path no longer contains additional line. I also have no numpy imported so I assume that the script was not executed for the worksheet.

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

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

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 sys
import os
import numpy as np
dev_path = os.path.join(os.path.expanduser("~"), 'Development') if dev_path not in sys.path:

then inside Sage I have:

sys.path.append(dev_path)
$ ~/Downloads/sage-6.10-Ubuntu_15.10-x86_64/sage ./sage  RecursionError: maximum recursion depth exceeded during compilation                                                                                   
┌────────────────────────────────────────────────────────────────────┐
│ SageMath Version 6.10, Release Date: 2015-12-18                    │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: sys.path
sage: sys.path[-1:]
['/home/eugene/Development']
np
<module 'numpy' from ....>

But then I run notebook(), notebook() and create a new worksheet, inside that worksheet and the sys.path no longer contains additional line. I also have no numpy imported so 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?

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

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?