problem installing mpmath v .17 in Python 3.2.1

361 views
Skip to first unread message

Richard D. Moores

unread,
Jul 27, 2011, 7:54:03 AM7/27/11
to mpm...@googlegroups.com
Win 64-bit Vista
Python 3.1.3 and 3.2.1

I need 3.2.1 in order to use gmpy2 (see http://code.google.com/p/gmpy/)

I downloaded http://mpmath.googlecode.com/files/mpmath-0.17.zip and
installed in Python 3.1.3 last February. I now have Python 3.2.1 and
tried the same installation, but get

>>> import mpmath
Traceback (most recent call last):
File "C:\Program Files (x86)\Wing IDE
4.0\src\debug\tserver\_sandbox.py", line 1, in <module>
# Used internally for debug sandbox under external interpreter
File "c:\Python32\Lib\site-packages\mpmath\__init__.py", line 5, in <module>
from .ctx_fp import FPContext
File "c:\Python32\Lib\site-packages\mpmath\ctx_fp.py", line 1, in <module>
from .ctx_base import StandardBaseContext
File "c:\Python32\Lib\site-packages\mpmath\ctx_base.py", line 3, in <module>
from .libmp.backend import xrange
File "c:\Python32\Lib\site-packages\mpmath\libmp\__init__.py", line
1, in <module>
from .libmpf import (prec_to_dps, dps_to_prec, repr_dps,
File "c:\Python32\Lib\site-packages\mpmath\libmp\libmpf.py", line
20, in <module>
from .libintmath import (giant_steps,
File "c:\Python32\Lib\site-packages\mpmath\libmp\libintmath.py",
line 302, in <module>
sqrtrem = gmpy.sqrtrem
builtins.AttributeError: 'module' object has no attribute 'sqrtrem'

What to do?

Thanks,

Dick Moores

casevh

unread,
Jul 28, 2011, 2:15:57 AM7/28/11
to mpmath


On Jul 27, 4:54 am, "Richard D. Moores" <rdmoo...@gmail.com> wrote:
> Win 64-bit Vista
> Python 3.1.3 and 3.2.1
>
> I need 3.2.1 in order to use gmpy2 (seehttp://code.google.com/p/gmpy/)
>

I commited several fixes for compatibility with gmpy2 since the 0.17
release.

For your particular issue, modify libintmath.py as follows:

Change the lines:

if BACKEND == 'gmpy':
isqrt_small = isqrt_fast = isqrt = gmpy.sqrt
sqrtrem = gmpy.sqrtrem

to:

if BACKEND == 'gmpy':
if gmpy.version() >= '2':
isqrt_small = isqrt_fast = isqrt = gmpy.isqrt
sqrtrem = gmpy.isqrt_rem
else:
isqrt_small = isqrt_fast = isqrt = gmpy.sqrt
sqrtrem = gmpy.sqrtrem


casevh

Richard D. Moores

unread,
Jul 28, 2011, 2:27:42 AM7/28/11
to mpm...@googlegroups.com
On Wed, Jul 27, 2011 at 23:15, casevh <cas...@gmail.com> wrote:
>
>
> On Jul 27, 4:54 am, "Richard D. Moores" <rdmoo...@gmail.com> wrote:
>> Win 64-bit Vista
>> Python 3.1.3 and 3.2.1
>>
>> I need 3.2.1 in order to use gmpy2 (seehttp://code.google.com/p/gmpy/)
>>
>
> I commited several fixes for compatibility with gmpy2 since the 0.17
> release.
>
> For your particular issue, modify libintmath.py as follows:
>
> Change the lines:
>
> if BACKEND == 'gmpy':
>   isqrt_small = isqrt_fast = isqrt = gmpy.sqrt
>   sqrtrem = gmpy.sqrtrem
>
> to:
>
> if BACKEND == 'gmpy':
>   if gmpy.version() >= '2':
>       isqrt_small = isqrt_fast = isqrt = gmpy.isqrt
>       sqrtrem = gmpy.isqrt_rem
>   else:
>       isqrt_small = isqrt_fast = isqrt = gmpy.sqrt
>       sqrtrem = gmpy.sqrtrem

Yes! That did it. Thanks very much.

Dick Moores

Reply all
Reply to author
Forward
0 new messages