Google Colab安装numpy==1.23.1无限循环,求解决方案
解决Google Colab中numpy 1.23.1安装无限循环的问题
问题复现
安装过程日志:
Collecting numpy==1.23.1 Using cached numpy-1.23.1.tar.gz (10.7 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: numpy
卡在构建wheel环节无限循环,已尝试降级Python至3.7/3.8/3.9、重装pip均无效。
可行解决方案
1. 强制使用预编译二进制包,跳过源码编译
Colab环境下源码编译numpy容易因为资源或依赖问题卡住,直接指定使用预编译wheel:
pip install numpy==1.23.1 --only-binary=numpy
如果上述命令依然报错,可直接指定从PyPI拉取预编译包:
pip install numpy==1.23.1 -f https://pypi.org/simple/numpy/ --no-index
2. 更新构建工具后再安装
numpy 1.23.1对setuptools、wheel版本有最低要求,先更新这些工具再尝试安装:
pip install --upgrade setuptools wheel pip pip install numpy==1.23.1
3. 清理pip缓存并重新安装
缓存的源码包可能损坏,清理后重新拉取资源:
pip cache purge pip install numpy==1.23.1
4. 使用conda安装(若Colab已配置conda环境)
conda会自动匹配预编译包,避免源码编译环节:
conda install numpy=1.23.1 -y
内容的提问来源于stack exchange,提问作者이예은
相关产品推荐
相关产品推荐

