Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to import a module at startup?

Hello, I'm new to sage and have been trying to import numpy when starting up sage for a few hours now. I've searched everywhere and so far i've tried the following options:

Editing the import_all variable in .sage/ipythonrc

import_all numpy

I've also tried adding some execute instructions in the ipythonrc

execute print "test"
execute from numpy import *

The thing is, the first line works and writes "test" to the console, but the import statement doesn't seem to work.

Finally, I've edited the main function in .sage/ipy_user_conf like this:

def main():
    from numpy import *
    o = ip.options
    ip.ex('from numpy import *')
main()

But this doesn't seem to work either. When I try to create a new column matrix like this:

a=matrix("[1; 2; 3; 4]")

I get an error which is solved by manually importing the numpy libs. Is there any other way to automatically load modules at startup? Am I missing something?

Thanks in advance for any help.

How to import a module at startup?

Hello, I'm new to sage and have been trying to import numpy when starting up sage for a few hours now. I've searched everywhere and so far i've tried the following options:

Editing the import_all variable in .sage/ipythonrc.sage/ipython/ipythonrc

import_all numpy

I've also tried adding some execute instructions in the ipythonrc

execute print "test"
execute from numpy import *

The thing is, the first line works and writes "test" to the console, but the import statement doesn't seem to work.

Finally, I've edited the main function in .sage/ipy_user_conf .sage/ipython/ipy_user_conf like this:

def main():
    from numpy import *
    o = ip.options
    ip.ex('from numpy import *')
main()

But this doesn't seem to work either. When I try to create a new column matrix like this:

a=matrix("[1; 2; 3; 4]")

I get an error which is solved by manually importing the numpy libs. Is there any other way to automatically load modules at startup? Am I missing something?

Thanks in advance for any help.