Ask Your Question

Levelpart's profile - activity

2019-02-17 02:25:27 -0600 received badge  Notable Question (source)
2015-03-09 08:44:48 -0600 received badge  Popular Question (source)
2012-04-27 15:06:00 -0600 received badge  Student (source)
2012-04-25 12:41:04 -0600 marked best answer How to import a module at startup?

I read somewhere that the .sage/init.sage file gets executed at startup, but I haven't tried it myself.

2012-04-25 12:41:04 -0600 received badge  Scholar (source)
2012-04-25 12:41:02 -0600 received badge  Supporter (source)
2012-04-25 12:38:56 -0600 commented answer How to import a module at startup?

Wow it worked! All this time searching and it was this easy, thanks a lot Tom. I still don't understand why some "execute" instructions in the iphythonrc wouldn't work though.

2012-04-25 12:36:22 -0600 received badge  Editor (source)
2012-04-25 12:28:21 -0600 asked a question 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/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/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.