首页 > 解决方案 > 如何在 Google Colab 上安装 gmpy2?

问题描述

我正在尝试通过以下命令在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”?此错误的原因可能是什么?

标签: ubuntupipgoogle-colaboratorypython-3.7gmpy

解决方案


以下是安装方法gmpy2

!apt install libmpc-dev
!pip install gmpy2

推荐阅读