项目场景:
在mac上使用miniforge遇到了这个问题,找了很久
问题描述
错误代码如下
Original error was: dlopen(/Users/user/miniforge3/envs/pth11env/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib
Referenced from: /Users/user/miniforge3/envs/pth11env/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so
Reason: tried: '/Users/user/miniforge3/envs/pth11env/lib/libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/lib/libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/lib/libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/lib/libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/lib/libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/bin/../lib/libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/lib/libcblas.3.dylib' (no such file), '/Users/user/miniforge3/envs/pth11env/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file)
}
原因分析:
这里提示
Reason: tried: ‘/Users/user/miniforge3/envs/pth11env/lib/libcblas.3.dylib’ (no such file), ‘/Users/user/miniforge3/envs/pth11env/lib/libcblas.3.dylib’ (no such file)…
可能是缺少文件
解决方案:
在网上查了一下说numpy依赖openblas,默认没有安装。手动安装openblas不完全,需要手动配置链接库软链。
conda install openblas//使用该命令安装openblas
conda list | grep blas//检查安装结果
到/Users/user/miniforge3/envs/pth11env/lib/路径下检查该文件
使用cat命令打开提示没有该文件
cat: libcblas.3.dylib: No such file or directory
但使用ls -al 可以看到该文件被软连接到libopenblas_vortexp-r0.3.18.dylib
于是排查libopenblas_vortexp-r0.3.18.dylib发现依旧提示不存在,于是建立软连接
ln -s libopenblas.dylib libopenblas_vortexp-r0.3.18.dylib
再次cat libcblas.3.dylib确认正常
在python中import torch正常。
参考:https://www.cnblogs.com/suanec/p/16014323.html