> .Well, not quite actually. The manual says define a SAGE_ROOT, but that's  
> not enough also.
> I foundhttp://wiki.sagemath.org/Sage_in_systemwide_python, but that example 
> also gives an error. When I added an environment variable SAGE_DOC (the error 
> was complaining about not finding it) it worked (using the LD_LIBRARY_PATH 
> line).

Actually I think the correct solution would be to add the line

export SAGE_DOC=$SAGE_ROOT/devel/sage/doc

to the wiki. However python does not complain about any other
directory..

----

Unfortunately for me there seems to be some awkward unforeseen error
if I run the script suggested in the wiki. Here I have some lenghty
output.. The questions are at the very bottom.

$ LD_LIBRARY_PATH="/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-
i686-Linux/local/lib/" python s.py
python: /home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/libz.so.1: no version information available (required by
python)
Traceback (most recent call last):
  File "s.py", line 46, in <module>
    import_sageall()
  File "s.py", line 32, in import_sageall
    import sage.all
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/all.py", line 44, in <module>
    import twisted.persisted.styles
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/twisted/__init__.py", line 18, in
<module>
    from twisted.python import compat
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/twisted/python/compat.py", line 15,
in <module>
    import sys, string, socket, struct
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python/socket.py", line 70, in <module>
    _realssl = ssl
NameError: name 'ssl' is not defined
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line
38, in apport_excepthook
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python2.6/dist-packages/apport/__init__.py", line 1,
in <module>
    from apport.report import Report
  File "/usr/lib/python2.6/dist-packages/apport/report.py", line 14,
in <module>
    import subprocess, tempfile, os.path, urllib, re, pwd, grp, os,
sys
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python/urllib.py", line 26, in <module>
    import socket
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python/socket.py", line 70, in <module>
    _realssl = ssl
NameError: name 'ssl' is not defined

Original exception was:
Traceback (most recent call last):
  File "s.py", line 46, in <module>
    import_sageall()
  File "s.py", line 32, in import_sageall
    import sage.all
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/all.py", line 44, in <module>
    import twisted.persisted.styles
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/twisted/__init__.py", line 18, in
<module>
    from twisted.python import compat
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/twisted/python/compat.py", line 15,
in <module>
    import sys, string, socket, struct
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python/socket.py", line 70, in <module>
    _realssl = ssl
NameError: name 'ssl' is not defined

And this is what I get if I call any other python script containing
"form sage.all import"...
Anyhow I've created a script "runsage" to be able to use it in the way
"runsage test.sage" with "test.sage" beeing e.g. "from sage.all import
*". It reads

export SAGE_ROOT=/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-
Linux
export SAGE_LOCAL=$SAGE_ROOT/local
export SAGE_DOC=$SAGE_ROOT/devel/sage/doc
export DOT_SAGE=~/.sage/
export PATH=$SAGE_ROOT/local/bin:$PATH
export LD_LIBRARY_PATH="$SAGE_ROOT/local/lib/openmpi:$SAGE_ROOT/local/
lib/:"
export PYTHONPATH="$SAGE_ROOT/local/bin:$SAGE_ROOT/local/lib/python2.5/
site-packages/setuptools-0.6c8-py2.5.egg:$SAGE_ROOT/local/lib/
python2.5/site-packages/SQLAlchemy-0.4.3-py2.5.egg:$SAGE_ROOT/local/
bin:$SAGE_ROOT/local/lib/python:$SAGE_ROOT/local/lib/python25.zip:
$SAGE_ROOT/local/lib/python2.5/plat-linux2:$SAGE_ROOT/local/lib/
python2.5/lib-tk:$SAGE_ROOT/local/lib/python2.5/lib-dynload:$SAGE_ROOT/
local/lib/python2.5/site-packages:$SAGE_ROOT/local/lib/python2.5/site-
packages/IPython/Extensions"
python $1

But again this results in an error:

./runsage tt.py
sh: sage: not found
Traceback (most recent call last):
  File "tt.py", line 5, in <module>
    from sage.all import *
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/all.py", line 94, in <module>
    from sage.server.all     import *
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/server/all.py", line 2, in
<module>
    from notebook.all import *
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/server/notebook/all.py", line
15, in <module>
    from notebook_object import notebook, inotebook
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/server/notebook/
notebook_object.py", line 19, in <module>
    import notebook as _notebook
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/server/notebook/notebook.py",
line 30, in <module>
    import worksheet    # individual worksheets (which make up a
notebook)
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/server/notebook/worksheet.py",
line 53, in <module>
    from   cell import Cell, TextCell
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/server/notebook/cell.py", line
44, in <module>
    if is_package_installed("tinyMCE"):
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/misc/package.py", line 161, in
is_package_installed
    return any(p.startswith(package) for p in install_package())
  File "/home/ivan/aps/sage-3.4.1-linux-Ubuntu_8.10-sse2-i686-Linux/
local/lib/python2.5/site-packages/sage/misc/package.py", line 118, in
install_package
    i = X.index('Currently installed packages:')
ValueError: list.index(x): x not in list

My solution is:
If I have sage code, where I do not mind to make use of the sage
interpreter I just write it in sage syntax and run it by "sage
code.sage"
If I want to stay in python, i run it by "sage code.py" and include
"from sage.all import *". This works for me and the code will work for
others who do not have this problem (i.e. can just type "python
sage.py").

My question: If I want to test a function from within a sage session
at the moment i type "import code.sage / code.py" and it runs. Clearly
this is not the best way to do it.. Any suggestions? (Please keep in
mind that "!python .." does not work for me).
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to