CygwinPortable 中 NumPy 无法安装
我正在使用 CygwinPortable,我将 Cygwin 环境装进了一个 U 盘里。
其中,Python 版本为:
Python 3.9.16 (main, Mar 8 2023, 22:47:22)
[GCC 11.3.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
我尝试安装 NumPy 失败了,出现了如下报错:
ERROR: Could not build wheels for numpy, which is required to install pyproject.
toml-based projects
根据提示安装 pyproject
执行如下命令:
pip3 install pyproject
安装完之后还是报错。
参考这个问题的链接:error: pyproject.toml-based projects
执行如下安装命令:
pip3 install psutil
报错信息显示 psutil
不支持 Windows 版本。 (这里的报错信息我也没保留)
转而参考博文:cygwin64安装pip2安装numpy
根据指导转到:解决pip的ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (xxxx)
博文认为关键在于更换 pip 版本。
执行如下命令:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
输出如下:
~$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2518k 100 2518k 0 0 503k 0 0:00:05 0:00:05 --:--:-- 492k
~$ python get-pip.py
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting pip
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/08/e3/57d4c24a050aa0bcc
a46b2920bff40847db79535dc78141eb83581a52eb8/pip-23.1.2-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 221.3 kB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.1.2
Uninstalling pip-23.1.2:
Successfully uninstalled pip-23.1.2
Successfully installed pip-23.1.2
执行完该命令后的报错信息我没能保留,大概的意思就是 NumPy 编译错误。
经过检查,发现可能的原因是在勾选安装工具的时候没有安装 python-devel 这个工具包。
在菜单中选择 Open Cygwin Setup
,选择安装 python39-devel
。
安装 NumPy 过程卡死。停滞在如下内容:
~$ pip3 install numpy
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting numpy
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2c/d4/590ae7df5044465c
c9fa2db152ae12468694d62d952b1528ecff328ef7fc/numpy-1.24.3.tar.gz (10.9 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: numpy
Building wheel for numpy (pyproject.toml) ... -
末尾的字符 -
仍在旋转,形如:
-
-> \
->|
-> /
-> -
但停滞数分钟。
换用如下命令:
/ $ pip install numpy --no-cache-dir
终端输出如下,依旧缓慢。
/ $ pip install numpy --no-cache-dir
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting numpy
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2c/d4/590ae7df5044465cc
9fa2db152ae12468694d62d952b1528ecff328ef7fc/numpy-1.24.3.tar.gz (10.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.9/10.9 MB 2.7 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: numpy
Building wheel for numpy (pyproject.toml) ... \
末尾的字符 -
仍在旋转,形如:
-
-> \
->|
-> /
-> -
但每一次旋转都要停滞数分钟。
已经等了几个小时了,依然卡在这个地方。