Forums

Error with Sympy

When I installed Sympy the following error occurs:

name 'long' is not defined

Request Method: GET

Request URL: http://susojuarez.pythonanywhere.com/

Django Version: 1.10

Exception Type: NameError

Exception Value: name 'long' is not defined

Exception Location: /usr/local/lib/python3.4/dist-packages/sympy/mpmath/libmp/backend.py in <module>, line 36

Python Executable: /usr/local/bin/uwsgi

Python Version: 3.4.3

On line 36 of sympy/mpmath/libmp/backend.py MPZ = long appears. How can I solve that? Thank you.

That's strange. The exact code in sympy is this:

try:
    xrange
    python3 = False
except NameError:
    python3 = True

BACKEND = 'python'

from .six import exec_, print_

if not python3:
    MPZ = long

So, it seems that even though you're running Python 3.4.3, xrange is somehow defined and so sympy thinks that you're on Python 2.x.

Do you have code anywhere that's defining xrange and somehow making it global?

I will review the software. Thank you very much.