【问题标题】:pip install module errorpip安装模块错误
【发布时间】:2023-04-25 07:17:01
【问题描述】:

大家好,我尝试使用pip install gmpy2 安装一个名为 gmpy2 的 python 模块,但在*构建过程中出现错误

running install
running build
running build_ext
building 'gmpy2' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-
prototypes -g -fdebug-prefix-map=/build/python3.6-LpWKty/python3.6-
3.6.5~rc1=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-
protector-strong -Wformat -Werror=format-security -Wdate-time -
D_FORTIFY_SOURCE=2 -fPIC -DWITHMPFR -DWITHMPC -
I/usr/include/python3.6m -c src/gmpy2.c -o build/temp.linux-x86_64-
3.6/src/gmpy2.o
In file included from src/gmpy2.c:426:0:
src/gmpy.h:252:12: fatal error: mpfr.h: No such file or directory
 #  include "mpfr.h"
            ^~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
`
`
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, 
tokenize;__file__='/tmp/pip-build-
onv0x975/gmpy2/setup.py';f=getattr(tokenize, 'open', open)
(__file__);code=f.read().replace('\r\n', 
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --
record /tmp/pip-izolloyr-record/install-record.txt --single-version-
externally-managed --compile" failed with error code 1 in /tmp/pip-
build-onv0x975/gmpy2/

我尝试了 pip 和 pip3

【问题讨论】:

标签: python python-3.x python-2.7 pip


【解决方案1】:

您需要下载 MPFR 源代码并进行编译。见安装手册:https://gmpy2.readthedocs.io/en/latest/intro.html#installation

【讨论】:

  • 您需要安装 GMP、MPFR 和 MPC 开发库。如果您安装“libmpc-dev”或同等版本,大多数 Linux 发行版都会安装这三个版本。