在安裝yolov5環境時,numpy安裝失敗報錯metadata-generation-failed
報錯如下:
Collecting numpy==1.18.5 (from -r /*****/yolov5-5.0/requirements.txt (line 5))Using cached https://pypi.tuna.tsinghua.edu.cn/packages/01/1b/d3ddcabd5817be02df0e6ee20d64f77ff6d0d97f83b77f65e98c8a651981/numpy-1.18.5.zip (5.4 MB)
......replace_method(CCompiler, 'find_executables', CCompiler_find_executables)NameError: name 'CCompiler' is not defined[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed× Encountered error while generating package metadata.
╰─> See above for output.note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
在python 3.7,3.8,3.9,3.10,3.12均無法正常安裝numpy,或報錯要求更高python版本。
遂調整requirements.txt的版本如下:
注:python要求3.8版本,否則torch可能無法安裝1.7.1。
# pip install -r requirements.txt# base ----------------------------------------
matplotlib==3.5.0
numpy==1.21.4
#numpy==1.18.5
opencv-python==4.5.4.60
Pillow==8.4.0
PyYAML==6.0
scipy==1.7.3
torch==1.7.1
#torch==1.7.0
torchvision>=0.8.1
tqdm==4.41.0# logging -------------------------------------
tensorboard==2.8.0
# wandb# plotting ------------------------------------
seaborn==0.11.2
pandas==1.3.4# export --------------------------------------
# coremltools==4.1
# onnx==1.8.1
# scikit-learn==0.19.2 # for coreml quantization# extras --------------------------------------
thop # FLOPS computation
pycocotools==2.0 # COCO mAP
發現torch安裝失敗,遂使用conda進行安裝:
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
此命令,conda將自動拉取所需依賴,并在虛擬環境下安裝cuda,和torch相關庫。
注:numpy被指定版本1.21.4, scipy被指定版本1.7.3
報錯:
ModuleNotFoundError: No module named 'Cython'
No matching distribution found for pycocotools==2.0
安裝對應庫:
pip install Cython pycocotools==2.0