Setting Up Mpmath: Download and Installation
Setting Up Mpmath: Download and Installation
Setting Up Mpmath: Download and Installation
Installer
The mpmath setup files can be downloaded from the Python Package Index. Download the source
package (available as both .zip and .tar.gz), extract it, open the extracted directory, and run
Using pip
Releases are registered on PyPI, so you can install latest release of the Mpmath with pip
Using setuptools
If you have setuptools installed, you can download and install mpmath in one step by running:
easy_install mpmath
or
If you have an old version of mpmath installed already, you may have to pass easy_install the -U
flag to force an upgrade.
Debian/Ubuntu
Debian and Ubuntu users can install mpmath with
See debian and ubuntu package information; please verify that you are getting the latest version.
OpenSUSE
Mpmath is provided in the “Science” repository for all recent versions of openSUSE. To add this
repository to the YAST software management tool, see
http://en.opensuse.org/SDB:Add_package_repositories
Note: if you have are upgrading mpmath from an earlier version, you may have to manually
uninstall the old version or remove the old files.
To verify that mpmath uses gmpy, check the internal variable BACKEND is not equal to ‘python’:
The gmpy mode can be disabled by setting the MPMATH_NOGMPY environment variable. Note
that the mode cannot be switched during runtime; mpmath must be re-imported for this change to
take effect.
Running tests
It is recommended that you run mpmath’s full set of unit tests to make sure everything works. The
tests are located in the tests subdirectory of the main mpmath directory. They can be run in the
interactive interpreter using the runtests() function:
import mpmath
mpmath.runtests()
python runtests.py
The tests should finish in about a minute. If you have psyco installed, the tests can also be run with
python build.py
You can also test that all the interactive examples in the documentation work by running
python run_doctest.py
Finally, some additional demo scripts are available in the demo directory included in the source
package.
----------------------------------------------------------------------
| Sage Version 4.1, Release Date: 2009-07-09 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: import mpmath
sage: mpmath.mp.dps = 50
sage: print mpmath.mpf(2) ** 0.5
1.4142135623730950488016887242096980785696718753769
The mpmath installation under Sage automatically use Sage integers for asymptotically fast
arithmetic, so there is no need to install GMPY:
sage: mpmath.libmp.BACKEND
'sage'
In Sage, mpmath can alternatively be imported via the interface library sage.libs.mpmath.all . For
example: