MacBook Air M1导入torchtext触发OSError问题求助
M1 MacBook Air安装torchtext后导入失败(OSError)
- 设备:MacBook Air M1
- 操作:通过
pip3完成torchtext安装,过程无报错 - 问题:执行
import torchtext时持续触发OSError,已尝试卸载重装相关组件但问题依旧 - 具体报错信息:
--------------------------------------------------------------------------- OSError Traceback (most recent call last) Input In [10], in <cell line: 1>() ----> 1 import torchtext File ~/Library/Python/3.8/lib/python/site-packages/torchtext/__init__.py:6, in <module> 3 from torch.hub import _get_torch_home 5 # the following import has to happen first in order to load the torchtext C++ library ----> 6 from torchtext import _extension # noqa: F401 8 _TEXT_BUCKET = "https://download.pytorch.org/models/text/" 10 _CACHE_DIR = os.path.expanduser(os.path.join(_get_torch_home(), "text")) File ~/Library/Python/3.8/lib/python/site-packages/torchtext/_extension.py:64, in <module> 59 # This import is for initializing the methods registered via PyBind11 60 # This has to happen after the base library is loaded 61 from torchtext import _torchtext # noqa ---> 64 _init_extension() File ~/Library/Python/3.8/lib/python/site-packages/torchtext/_extension.py:58, in _init_extension() 55 if not _mod_utils.is_module_available("torchtext._torchtext"): 56 raise ImportError("torchtext C++ Extension is not found.") ---> 58 _load_lib("libtorchtext") 59 # This import is for initializing the methods registered via PyBind11 60 # This has to happen after the base library is loaded 61 from torchtext import _torchtext File ~/Library/Python/3.8/lib/python/site-packages/torchtext/_extension.py:50, in _load_lib(lib) 48 if not path.exists(): 49 return False ---> 50 torch.ops.load_library(path) 51 return True File ~/Library/Python/3.8/lib/python/site-packages/torch/_ops.py:220, in _Ops.load_library(self, path) 215 path = torch._utils_internal.resolve_library_path(path) 216 with dl_open_guard(): 217 # Import the shared library into the process, thus running its 218 # static (global) initialization code in order to register custom 219 # operators with the JIT. ---> 220 ctypes.CDLL(path) 221 self.loaded_libraries.add(path) File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py:365, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode) 362 self._FuncPtr = _FuncPtr 364 if handle is None: ---> 365 self._handle = _dlopen(self._name, mode) 366 else: 367 self._handle = handle OSError: dlopen(/Users/pratik/Library/Python/3.8/lib/python/site-packages/torchtext/lib/libtorchtext.so, 0x0006): Symbol not found: __ZN3c1012OptionalType3getENS_4Type24SingletonOrSharedTypePtrIS1_EE Referenced from: /Users/pratik/Library/Python/3.8/lib/python/site-packages/torchtext/lib/libtorchtext.so Expected in: /Users/pratik/Library/Python/3.8/lib/python/site-packages/torch/lib/libtorch_cpu.dylib
内容的提问来源于stack exchange,提问作者Pratik Karmakar
相关产品推荐
相关产品推荐

