出现的问题:
当我安装h5py包时,出现了以下报错:
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'd:\\anaconda3\\envs\\ser\\lib\\site-packages\\numpy-1.24.2.dist-info\\METADATA'
这说明h5py与numpy之间是存在依赖关系的。(很多包与numpy之间都存在依赖关系)
原因分析:
顺着报错的路径找到numpy-1.24.2.dist-info所在的文件夹,发现还存在着低版本的numpy
于是发现numpy-1.23.5.dist-info中的文件是这样的:
而 numpy-1.24.2.dist-info中只有LICENSES_bundled.txt,没有报错中提到的METADATA.
猜测为执行pip install --upgrade numpy后创建了新版本的文件夹,但其中与旧版本相同的文件并不会被放入新版本的文件夹里。
解决方式:
因此只需将numpy-1.23.5.dist-info中的全部文件复制到numpy-1.24.2.dist-info中,文件名相同的选择跳过。
这样一来就不会再报这个错了!