python - 如何安装gmpy2错误: ‘MPFR_RNDU’ undeclared (first use in this function)

标签 python installation gmpy

我像这样安装 gmpy2:

yum install gmp-devel
yum install mpfr-devel
yum install libmpc-devel

但显示这些错误:

src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘real_round’

src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘real_round’

src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘imag_round’

src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘underflow’

src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘trap_underflow’

src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘overflow’

src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘trap_overflow’

src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘inexact’

 src/gmpy_mpc.c:1294: error: ‘gmpy_context’ has no member named ‘trap_inexact’

..........


src/gmpy2.c:969: error: ‘MPFR_RNDU’ undeclared (first use in this function)

src/gmpy2.c:970: error: ‘MPFR_RNDD’ undeclared (first use in this function)

src/gmpy2.c:971: error: ‘MPFR_RNDA’ undeclared (first use in this function)

error: command 'gcc' failed with exit status 1

怎么了?我已经安装了 gmp、mpfr、mpc 和他们的开发,,, 但仍然有很多错误。为什么?

最佳答案

我是 gmpy2 的维护者。

gmpy2 需要相对较新版本的 MPFR 和 MPC。如果setup.py找不到合适的版本,它将显示以下警告消息:

----------------------------------------------------------------
setup.py was not able to detect the required versions of MPFR
and/or MPC. gmpy2 requires MPFR version 3.1.0 or greater and
MPC version 1.0.0 or greater. To specify a directory prefix that
contains the proper versions, use the --prefix=<dir> option.

In some circumstances, the correct versions may be present and
this warning can be ignored. If you have difficulties compiling
or running gmpy2, please try compiling with the --prefix option.

It is possible to compile gmpy2 without support for MPFR and MPC
but that is not a supported configuration. Beginning with v2.1.0,
MPFR and MPC will be required.

setup.py will continue and attempt to compile gmpy2.
-----------------------------------------------------------------

如果您无法安装最新版本的 GMP、MPFR 和 MPC,那么您需要编译自己版本的 GMP、MPFR 和 MPC,然后指示 setup.py使用您的版本。我通常将副本安装到 /opt/local 中。以下说明假设源位于 /opt/local/src 中,并且您使用具有 sudo 访问权限的管理员帐户。

$ cd /opt/local/src/gmp-6.0.0
$ ./configure --prefix=/opt/local
$ make
$ make check
$ make install
$ cd /opt/local/src/mfr-3.1.2
$ ./configure --prefix=/opt/local --with-gmp=/opt/local
$ make
$ make check
$ make install
$ cd /opt/local/src/mpc-1.0.2
$ ./configure --prefix=/opt/local --with-gmp=/opt/local --with-mpfr=/opt/local
$ make
$ make check
$ make install
$ cd /opt/local/src/gmpy2-2.0.3
$ python setup.py build_ext --prefix=/opt/local
$ sudo python setup.py install

如果您需要在各种系统(实验室或计算机集群)上分发gmpy2库,可以编译静态链接版本。如果您需要这些说明,请告诉我。

关于python - 如何安装gmpy2错误: ‘MPFR_RNDU’ undeclared (first use in this function),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25704776/

相关文章:

python - python请求的理想 block 大小

visual-studio-2012 - WiX Bootstrap 应用程序

Windows 10 上的 IIS 媒体服务

ubuntu - 如何在 Google Colab 上安装 gmpy2?

python - gmpy2 有 "e=2.1718..."常量吗?

python - matplotlib hexbins 中的十六进制大小基于附近点的密度

python - 如何计算2个目录路径之间的相对路径?

python - 如何删除字符串开头的一定数量的字符

windows - 安装到特定用户文件夹更改为安装到当前用户文件夹

python bigfloat安装问题