upiterbarg/mpmath

python-mpmath fails if sage packages installed

GoogleCodeExporter opened this issue · 3 comments

  Example of execution:

$ rpm -q sagemath
sagemath-4.7.2-2-mdv2012.0.x86_64
$ export MPMATH_NOSAGE=1
$ python

Python 2.7.2 (default, Aug 30 2011, 03:39:21) 
[GCC 4.6.1 20110826 (Mandriva)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mpmath
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/mpmath/__init__.py", line 6, in <module>
    from .ctx_mp import MPContext
  File "/usr/lib/python2.7/site-packages/mpmath/ctx_mp.py", line 48, in <module>
    from sage.libs.mpmath.ext_main import Context as BaseMPContext
  File "parent.pxd", line 11, in init sage.libs.mpmath.ext_main (sage/libs/mpmath/ext_main.c:24996)
  File "element.pxd", line 12, in init sage.structure.parent (sage/structure/parent.c:21563)
  File "element.pyx", line 184, in init sage.structure.element (sage/structure/element.c:28577)
  File "/usr/lib64/python2.7/site-packages/sage/misc/sageinspect.py", line 161, in <module>
    SAGE_ROOT = os.environ["SAGE_ROOT"]
  File "/usr/lib64/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'SAGE_ROOT'
>>> 

  I think it should need some different machinery to know if
should or not attempt to load sage modules.

Original issue reported on code.google.com by paulo.ce...@gmail.com on 10 Nov 2011 at 2:55

MPMATH_NOSAGE=1 *should* be fixed already in the svn version of mpmath. Can you 
verify this?

Original comment by fredrik....@gmail.com on 10 Nov 2011 at 3:05

Yes, I confirm it is fixed. Actually, it appears to work
regardless of setting or not MPMATH_NOSAGE=1 when
sage is installed.

Original comment by paulo.ce...@gmail.com on 10 Nov 2011 at 3:24

The problem happens again, now in my Fedora sagemath package:
https://bugzilla.redhat.com/show_bug.cgi?id=974769
Can only "import mpmath" in python if under "sage -sh".
Apparently the MPMATH_NOSAGE environment variable is
also ignored.

Original comment by paulo.ce...@gmail.com on 19 Jun 2013 at 12:37