Ask Your Question
1

Sage uses system-wide python...

asked 2012-05-26 14:55:08 +0100

bk322 gravatar image

updated 2015-01-13 20:47:00 +0100

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)
edit retag flag offensive close merge delete

Comments

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

Volker Braun gravatar imageVolker Braun ( 2012-05-27 01:51:20 +0100 )edit

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

bk322 gravatar imagebk322 ( 2012-05-27 03:56:35 +0100 )edit

3 Answers

Sort by » oldest newest most voted
3

answered 2012-05-29 04:22:05 +0100

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; }
edit flag offensive delete link more
2

answered 2012-10-14 17:19:25 +0100

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.

edit flag offensive delete link more
1

answered 2012-10-15 07:02:18 +0100

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.

edit flag offensive delete link more

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: 2012-05-26 14:55:08 +0100

Seen: 1,311 times

Last updated: Oct 15 '12