目录
  1. 系统环境
  2. 错误信息
  3. 解决方法
Pytorch ImportError报错解决方法

系统环境

系统环境:Mac Pro
程序环境:python 3.7

  • 刚刚安装完torch后,运行提示缺少 from torch._C import *

错误信息

1
2
3
4
5
6
7
8
Traceback (most recent call last):
File "/Users/haibei/Documents/Airly/new-pollution-forecast/Datasets/__init__.py", line 3, in <module>
from torch.utils.data import Dataset
File "/Users/kaspersapala/.local/share/virtualenvs/new-pollution-forecast-BSetKF9E/lib/python3.7/site-packages/torch/__init__.py", line 79, in <module>
from torch._C import *
ImportError: dlopen(/Users/haibei/.local/share/virtualenvs/new-pollution-forecast-BSetKF9E/lib/python3.7/site-packages/torch/_C.cpython-37m-darwin.so, 9): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
Referenced from: /Users/kaspersapala/.local/share/virtualenvs/new-pollution-forecast-BSetKF9E/lib/python3.7/site-packages/torch/lib/libshm.dylib
Reason: image not found

解决方法

  • 需要安装libomp,不知道是干啥的,好像跟C的编译器有关系
1
brew install libomp
文章作者: Haibei
文章链接: http://www.haibei.online/posts/829459397.html
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Haibei的博客
打赏
  • 微信
  • 支付宝

评论