ImportError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import torch
File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/torch/__init__.py:202, in <module>
200 if USE_GLOBAL_DEPS:
201 _load_global_deps()
--> 202 from torch._C import * # noqa: F403
204 # Appease the type checker; ordinarily this binding is inserted by the
205 # torch._C module initialization code in C
206 if TYPE_CHECKING:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/torch/_C.cpython-39-darwin.so, 2): Library not loaded: @loader_path/../.dylibs/libomp.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/torch/lib/libtorch_cpu.dylib
Reason: no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/torch/lib/../.dylibs/libomp.dylib: cannot load 'libomp.dylib' (load command 0x80000034 is unknown)
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/torch/lib/../.dylibs/libomp.dylib: cannot load 'libomp.dylib' (load command 0x80000034 is unknown)
这是我在使用Jupyter笔记本电脑时在MacOs上遇到的错误。我已经使用命令“pip3 install torch torchvision torchaudio”安装了Pytorch,并且它显示已经安装成功。我尝试安装Anaconda,但是Anaconda安装失败,所以,使用pip3安装了torch。
原因是什么?我该怎么解决这个问题?
我正在尝试并期望解决此错误。
1条答案
按热度按时间ar7v8xwq1#
检查您的解释器(您目前使用的python版本)。
要检查Jupyter笔记本中的Python版本,首先用“from platform import python_version“导入python_version函数,然后调用函数python_version(),返回一个字符串,其中包含Jupyter笔记本中运行的版本号,例如(“3.7.11”)〈- example。
然后检查您正在使用的python版本是否与此操作过程中给定的版本相同。