UKPLab / sentence-transformers

State-of-the-Art Text Embeddings
https://www.sbert.net
Apache License 2.0
15.28k stars 2.48k forks source link

cant import BertModel when installed by conda #1642

Closed chenjinhongv closed 2 years ago

chenjinhongv commented 2 years ago

when install sentence-transformers by conda, which use command below: conda install -c conda-forge sentence-transformers then try to import BertModel, which raise an error below:

Traceback(most recent call last): File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/utils/import_ut return importlib.import_module("." + module_name, self.name) File "/home/tools/anaconda3/envs/test1/lib/python3.7/importlib/init.py", line 127, in impor return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/tokenization_ut from .tokenization_utils_base import ( File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/tokenization_ut from tokenizers import AddedToken File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/tokenizers/init.py", lin from .tokenizers import ( ImportError: libssl.so.3: cannot open shared object file: No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/utils/import_ut return importlib.import_module("." + module_name, self.name) File "/home/tools/anaconda3/envs/test1/lib/python3.7/importlib/init.py", line 127, in impor return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 953, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/models/init from . import ( File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/models/layoutlm> from .configuration_layoutlm import LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP, LayoutLMConfig File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/models/layoutlm19, in from transformers import PretrainedConfig, PreTrainedTokenizer, TensorType File "", line 1032, in _handle_fromlist File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/utils/import_ut module = self._get_module(self._class_to_module[name]) File "/home/tools/anaconda3/envs/test1/lib/python3.7/site-packages/transformers/utils/import_ut ) from e RuntimeError: Failed to import transformers.tokenization_utils because of the following error (lo libssl.so.3: cannot open shared object file: No such file or directory

my environment below:

Ubuntu 18.04.6 LTS Python 3.7.13 conda 4.13.0

when install sentence-transformers by pip pip install -U sentence-transformers no error accured

nreimers commented 2 years ago

Appears to be an issue with transformers and missing libssl. Sadly cannot help here.