For starters, you need Sage's python2, so that at its python prompt you can do
>>> from sage.all import * and this works. Are you already at this point? On Thu, Sep 27, 2018 at 2:37 PM Abhishek Kesarwani <1907a...@gmail.com> wrote: > > I am trying to run Example 2: And getting following error. Please help me. > abc@Math-Sans:~/Desktop$ gcc -I/usr/include/python2.7 ABC.c -lpython2.7 -lm > -lutil -lpthread -ldl > abc@Math-Sans:~/Desktop$ ./a.out > 1+1: > 2 > Load sage > Traceback (most recent call last): > File "<string>", line 1, in <module> > ImportError: No module named sage.all > Factor 2310: > Traceback (most recent call last): > File "<string>", line 1, in <module> > NameError: name 'factor' is not defined > > On Tuesday, September 13, 2011 at 9:16:05 PM UTC+5:30, Michael Rubinstein > wrote: >> >> >> I tried adding PySys_SetArgv(argc, argv); after Py_Initialize(); >> It gets me further but then gives a strange error message: >> >> Loading the Sage library... >> >> >> ------------------------------------------------------------ >> Unhandled SIGSEGV: A segmentation fault occurred in Sage. >> This probably occurred because a *compiled* component >> of Sage has a bug in it (typically accessing invalid memory) >> or is not properly wrapped with _sig_on, _sig_off. >> You might want to run Sage under gdb with 'sage -gdb' to debug this. >> Sage will now terminate (sorry). >> ------------------------------------------------------------ >> >> >> >> >> On Sep 13, 2:32 pm, Willem Jan Palenstijn <w...@usecode.org> wrote: >> > On Tue, Sep 13, 2011 at 06:10:45AM -0700, Michael Rubinstein wrote: >> > > Example 2 >> > > ---------------- >> > >> > > Next thing I tried to do was to embed sage in a c program, by >> > > following >> > >http://docs.python.org/extending/embedding.html >> > > but that gave me errors at runtime. >> > >> > > For example, the following embed.c progam produced the output/errors at >> > > the >> > > bottom of this post. Any ideas what's wrong? Any ideas of better ways to >> > > call >> > > sage from within c or c++? >> > >> > Some quick googling suggests you may have to call PySys_SetArgv[Ex] >> > (http://docs.python.org/c-api/init.html#PySys_SetArgvEx) to set up sys.argv >> > after calling Py_Initialize(). I haven't actually tried it, though. >> > >> > -Willem Jan > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.