【问题标题】:How to install GNU MPFR library on pythonanywhere如何在 pythonanywhere 上安装 GNU MPFR 库
【发布时间】:2024-01-19 11:11:01
【问题描述】:

我正在尝试安装bigfloat,我收到这条消息似乎表明我首先需要mpfr 库。我该怎么做?
消息:

运行 build_ext 构建 'mpfr' 扩展创建 build/temp.linux-x86_64-2.7 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes - fPIC -I/usr/include/python2.7 -c mpfr。 c -o build/temp.linux-x86_64-2.7/mpfr.o mpfr.c:344:18: 致命错误: mpfr.h: No such file or directory #include "mpfr.h" ^ 编译终止。错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为 1

我对 python 和 pythonanywhere 还很陌生,所以我不知道如何安装库。

我试图找到如何使用谷歌安装库,我尝试使用:

pip install --user mpfr 

但我收到此错误消息:

正在收集 mpfr 找不到满足 mpfr 要求的版本(来自版本:)没有找到 mpfr 的匹配分布

【问题讨论】:

  • 错误信息是什么?你试过什么?
  • 消息:运行 build_ext 构建 'mpfr' 扩展创建 build/temp.linux-x86_64-2.7 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv - O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c mpfr。 c -o build/temp.linux-x86_64-2.7/mpfr.o mpfr.c:344:18: 致命错误: mpfr.h: No such file or directory #include "mpfr.h" ^ 编译终止。错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为 1 我对 python 和 pythonanywhere 还很陌生,所以我不知道如何安装库。
  • 我试图找到如何使用 google 安装库,并尝试使用:pip install --user mpfr 但我收到此错误消息:收集 mpfr 找不到满足要求的版本mpfr(来自版本:)没有为 mpfr 找到匹配的分布

标签: python python-3.x gnu pythonanywhere mpfr


【解决方案1】:

gmpy2 是用 C 语言编写的,并且依赖于其他三个 C 库:GMP、MPFR 和 MPC。确保所有依赖项都存在的最简单方法是使用 Linux 发行版中的标准包管理工具“libmpc-dev”。 例如:

sudo apt-get install libmpc-dev 

【讨论】:

  • 供 CentOS 使用:yum install libmpc-devel