First time here? Check out the FAQ!

Ask Your Question
1

Sage uses system-wide python...

asked 12 years ago

bk322 gravatar image

updated 10 years ago

FrédéricC gravatar image

I've just compiled the latest sage, it tries to import my system-wide ipython instead of its own - and won't run:

./sage
----------------------------------------------------------------------
| Sage Version 5.0, Release Date: 2012-05-14                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/boris/its/soft/sft/sage-5.0-x86_64/local/bin/sage-ipython", line 18, in <module>
    import IPython
  File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 46, in <module>
    from .frontend.terminal.embed import embed
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/embed.py", line 37, in <module>
    from IPython.frontend.terminal.ipapp import load_default_config
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 38, in <module>
    from IPython.core.completer import IPCompleter
  File "/usr/lib/python2.7/dist-packages/IPython/core/completer.py", line 84, in <module>
    from IPython.utils import generics
  File "/usr/lib/python2.7/dist-packages/IPython/utils/generics.py", line 19, in <module>
    from IPython.external.simplegeneric import generic
  File "/usr/lib/python2.7/dist-packages/IPython/external/simplegeneric/__init__.py", line 4, in <module>
    from _simplegeneric import *
ImportError: No module named _simplegeneric

Edit:

I purged my ~/.config/ipython as well as ~/.sage. No help. I tried to load sage's ipython manually:

import imp
IPython = imp.imp.load_source('IPython', os.environ['SAGE_ROOT']+'/local/lib/python2.7/site-packages/IPython/__init__.py')

Now it gives another error:

/home/boris/its/soft/sft/sage-5.0-x86_64
Traceback (most recent call last):
  File "/home/boris/its/soft/sft/sage-5.0-x86_64/local/bin/sage-ipython", line 21, in <module>
    IPython = imp.load_source('IPython', os.environ['SAGE_ROOT']+'/local/lib/python2.7/site-packages/IPython/__init__.py')
  File "/home/boris/its/soft/sft/sage-5.0-x86_64/local/lib/python2.7/site-packages/IPython/__init__.py", line 58, in <module>
    __import__(name,glob,loc,[])
ImportError: No module named ipapi

Edit 2:

./sage -sh
echo $PYTHONPATH

gives me

/home/boris/its/soft/sft/sage-5.0-x86_64/local/lib/python

What does Your sage gives You in that case?

Edit 3:

Here's a list of all of my environment variables (obtained with set -o posix ; set):

BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist:expand_aliases:extglob:extquote:force_fignore:histappend:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_COMPLETION=/etc/bash_completion
BASH_COMPLETION_COMPAT_DIR=/etc/bash_completion.d
BASH_COMPLETION_DIR=/etc/bash_completion.d
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="2" [2]="24" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")
BASH_VERSION='4.2.24(1)-release'
COLORFGBG='0;15'
COLUMNS=137
COMP_WORDBREAKS='   
"'\''><=;|&(:'
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-fP3EcB8b5v,guid=e608bfdcea2634dcce5aa08c00000039
DEFAULTS_PATH=/usr/share/gconf/kde-plasma.default.path
DESKTOP_SESSION=kde-plasma
DIRSTACK=()
DISPLAY=:0
DM_CONTROL=/var/run/xdmctl
EUID=1000
GPG_AGENT_INFO=/tmp/gpg-PpUHRE/S.gpg-agent:1495:1
GROUPS=()
GS_LIB=/home/boris/.fonts
GTK2_RC_FILES=/home/boris/.gtkrc-2.0-kde4
GTK_MODULES=canberra-gtk-module:canberra-gtk-module
HISTCONTROL=ignoredups:ignorespace
HISTFILE=/home/boris/.bash_history
HISTFILESIZE=2000
HISTSIZE=1000
HISTTIMEFORMAT='%T '
HOME=/home/boris
HOSTNAME=vasilisa
HOSTTYPE=x86_64
IFS='   
'
KDE_FULL_SESSION=true
KDE_SESSION_UID=1000
KDE_SESSION_VERSION=4
KONSOLE_DBUS_SERVICE=:1.115
KONSOLE_DBUS_SESSION=/Sessions/1
LANG=en_US.UTF-8
LANGUAGE=
LESSCLOSE='/usr/bin/lesspipe %s %s'
LESSOPEN='| /usr/bin/lesspipe %s'
LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr ...
(more)
Preview: (hide)

Comments

Do you have some environment variables set up that point Python in the wrong place? For example, PYTHONPATH?

Volker Braun gravatar imageVolker Braun ( 12 years ago )

I'm using custom PYTHONPATH, but now I turned it off: `echo $PYTHONPATH` gives nothing. But still the error comes up.

bk322 gravatar imagebk322 ( 12 years ago )

3 Answers

Sort by » oldest newest most voted
3

answered 12 years ago

bk322 gravatar image

Oh, I solved it.

I have latest numpy, scipy, matplotlib installed at

~/.local/lib/python2.7/site-packages

and it makes sage crazy - both during compilation and during the usage.

So renaming that lib directory to lib~ allows one to use sage. Here's a bash function which toggles reanming of lib:

bk-tgls-lcl-lib () { if [ -e ~/.local/lib ]; then mv ~/.local/lib ~/.local/lib~ && echo '!!! Now it is lib~'; else mv ~/.local/lib~ ~/.local/lib && echo '!!! Now it is lib'; fi; }
Preview: (hide)
link
2

answered 12 years ago

Gong-Yi Liao gravatar image

Another quick hack:

cd $SAGE_ROOT/local/lib/python
cp -r site-packages/IPython ./.

Then run sage again, I think it will use the IPython package shipped with Sage.

Preview: (hide)
link
1

answered 12 years ago

Volker Braun gravatar image

Can you try

export PYTHONNOUSERSITE=yes
sage

This should prevent Sage from picking up stuff in .local/lib. If that fixes your problem we can add it to the next release.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 1,331 times

Last updated: Oct 15 '12