Ask Your Question

Levelpart's profile - activity

2019-02-17 09:25:27 +0200 received badge  Notable Question (source)
2015-03-09 14:44:48 +0200 received badge  Popular Question (source)
2012-04-27 22:06:00 +0200 received badge  Student (source)
2012-04-25 19:41:04 +0200 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 19:41:04 +0200 received badge  Scholar (source)
2012-04-25 19:41:02 +0200 received badge  Supporter (source)
2012-04-25 19:38:56 +0200 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 19:36:22 +0200 received badge  Editor (source)
2012-04-25 19:28:21 +0200 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 *')

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.