问题
I want to use the jacobDN function in sympy, so I download it and python setup.py install
it, successfully.
When I want to use it as in the documentation does:
>>> from sympy.mpmath import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mpmath
>>>
Import everything from sympy is successful:
>>> from sympy import *
>>>
Then I installed mpmath individually, then I can use the ellipfun from mpmath. However an annoying mpf
is shown:
>>> from mpmath import *
>>> ellipfun('dn',0.5,0.5)
mpf('0.94297242577738571')
>>>
Question is how to use ellipfun under sympy.mpmath? How to check my install flaws?
The solution to the above is the best! If can't, how can I use ellipfun in mpmath just as using the normal functions?
evidence of the successful installation of sympy
-> ~$ pip show sympy
---
Name: sympy
Version: 0.7.7.dev
Location: /usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev-py2.7.egg
Requires: mpmath
-> ~$ pip install --upgrade sympy
Requirement already up-to-date: sympy in /usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev-py2.7.egg
Requirement already up-to-date: mpmath>=0.19 in /usr/local/lib/python2.7/dist-packages/mpmath-0.19-py2.7.egg (from sympy)
Cleaning up...
回答1:
In the development version of SymPy, which is what you have installed, sympy.mpmath
has been removed. mpmath is now an external library, so you need to install and import it separately, as you have done.
The two versions are exactly the same (there haven't been any mpmath releases in a while).
mpmath doesn't support numpy arrays, as far as I know. You need to use scipy.special
if you want to do that. You should only use mpmath if you are interested in multiprecision floats (beyond machine precision). If you are interested in that, you can also use sympy.Float
, which is a wrapper around mpf
which plays nicely with SymPy objects.
回答2:
I would recommend using the non-development version. SymPy 0.7.6 is the last version that will have mpmath packaged with SymPy. In the future it will be a dependency. Since you installed the development version you have to install mpmath independently.
来源:https://stackoverflow.com/questions/34214635/sympy-installed-however-sympy-mpmath-not-found