如何在 Google Colab 上安装 gmpy2?

How to install gmpy2 on Google Colab?

我正在尝试通过以下命令在 Google Colab 上安装 "gmpy2"

!pip3 install gmpy2

我收到错误:

Collecting gmpy2
  Downloading gmpy2-2.0.8.zip (280 kB)
     |████████████████████████████████| 280 kB 5.0 MB/s 
Building wheels for collected packages: gmpy2
  Building wheel for gmpy2 (setup.py) ... error
  ERROR: Failed building wheel for gmpy2
  Running setup.py clean for gmpy2
Failed to build gmpy2
Installing collected packages: gmpy2
    Running setup.py install for gmpy2 ... error
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vgotfc49/gmpy2_497ebb8b22424194b2bbd366af5942b6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vgotfc49/gmpy2_497ebb8b22424194b2bbd366af5942b6/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xvhw4sjx/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/gmpy2 Check the logs for full command output.

Google Colab 致力于 说明:Ubuntu 18.04.5 LTS 代号:仿生 型号名称:AMD EPYC 7B12

pip3 --version
pip 21.1.3 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)

为什么我无法安装 "gmpy2"?出现此错误的原因可能是什么?

安装方法如下gmpy2

!apt install libmpc-dev
!pip install gmpy2