最小示例:
pip install tensorflow==2.9.1 non-existing==1.2.3
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting tensorflow==2.9.1
Downloading tensorflow-2.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (511.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 511.7/511.7 MB 7.6 MB/s eta 0:00:00
ERROR: Could not find a version that satisfies the requirement non-existing==1.2.3 (from versions: none)
ERROR: No matching distribution found for non-existing==1.2.3
所以pip
首先下载(相当大的)TensorFlow,但then告诉我non-existing
不存在.
有没有办法让它更早失败,例如,打印错误并退出before下载?