import torch 报错,from torch._C import * ImportError: dlopen.... Reason: image not found

电脑MacBookpro python3.7

pip 安装pytorch后,import torch报错

from torch._C import *

ImportError: dlopen....      

Reason: image not found

 

 网上各种搜索着解决方案,最终使用如下命令成功解决:

brew install libomp

本人使用其他方法均为解决。亲测无效的命令如下:

亲测无效方法1.

pip3 install --upgrade pip

亲测无效方法2.

pip install pymysql

亲测无效方法3. 

otool -L /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/_C.cpython-37m-darwin.so 

install_name_tool -change @rpath/libc++.1.dylib /usr/lib/libc++.1.dylib /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/_C.cpython-37m-darwin.so

也有朋友使用这三种方法成功解决的。也为大家总结在这里,大家可以自行尝试。

你可能感兴趣的:(linux)