笔记:在使用ModelScope中遇见相关依赖版本不兼容问题

在运行下面程序后,发生了报错

python -c "from modelscope.pipelines import pipeline;print(pipeline('word-segmentation')('今天天气不错,适合 出去游玩'))"

报错:

2023-05-29 18:14:16,979 - modelscope - INFO - PyTorch version 1.11.0+cpu Found.
2023-05-29 18:14:16,979 - modelscope - INFO - Loading ast index from C:\Users\RedmiBook\.cache\modelscope\ast_indexer
2023-05-29 18:14:16,994 - modelscope - INFO - No valid ast index found from C:\Users\RedmiBook\.cache\modelscope\ast_indexer, generating ast index from prebuilt!
2023-05-29 18:14:17,437 - modelscope - INFO - Loading done! Current index file version is 1.6.0, with md5 22a5ac335dddf24fa86adbce934d360e and a total number of 848 components indexed
Traceback (most recent call last):
  File "", line 1, in <module>
  File "D:\ANACONDA\lib\site-packages\modelscope\pipelines\__init__.py", line 4, in <module>
    from .base import Pipeline
  File "D:\ANACONDA\lib\site-packages\modelscope\pipelines\base.py", line 16, in <module>
    from modelscope.msdatasets import MsDataset
  File "D:\ANACONDA\lib\site-packages\modelscope\msdatasets\__init__.py", line 2, in <module>
    from .ms_dataset import MsDataset
  File "D:\ANACONDA\lib\site-packages\modelscope\msdatasets\ms_dataset.py", line 16, in <module>
    from modelscope.msdatasets.data_loader.data_loader import VirgoDownloader
  File "D:\ANACONDA\lib\site-packages\modelscope\msdatasets\data_loader\data_loader.py", line 15, in <module>
    from modelscope.msdatasets.data_files.data_files_manager import \
  File "D:\ANACONDA\lib\site-packages\modelscope\msdatasets\data_files\data_files_manager.py", line 11, in <module>
    from modelscope.msdatasets.download.dataset_builder import (
  File "D:\ANACONDA\lib\site-packages\modelscope\msdatasets\download\dataset_builder.py", line 23, in <module>
    from modelscope.msdatasets.download.download_manager import \
  File "D:\ANACONDA\lib\site-packages\modelscope\msdatasets\download\download_manager.py", line 9, in <module>
    from modelscope.msdatasets.utils.oss_utils import OssUtilities
  File "D:\ANACONDA\lib\site-packages\modelscope\msdatasets\utils\oss_utils.py", line 7, in <module>
    import oss2
  File "D:\ANACONDA\lib\site-packages\oss2\__init__.py", line 15, in <module>
    from .resumable import resumable_upload, resumable_download, ResumableStore, ResumableDownloadStore, determine_part_size
  File "D:\ANACONDA\lib\site-packages\oss2\resumable.py", line 19, in <module>
    from .crypto_bucket import CryptoBucket
  File "D:\ANACONDA\lib\site-packages\oss2\crypto_bucket.py", line 10, in <module>
    from .crypto import BaseCryptoProvider
  File "D:\ANACONDA\lib\site-packages\oss2\crypto.py", line 21, in <module>
    from aliyunsdkcore import client
  File "D:\ANACONDA\lib\site-packages\aliyunsdkcore\client.py", line 32, in <module>
    from aliyunsdkcore.vendored.requests import codes
  File "D:\ANACONDA\lib\site-packages\aliyunsdkcore\vendored\requests\__init__.py", line 48, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "D:\ANACONDA\lib\site-packages\aliyunsdkcore\vendored\requests\packages\urllib3\contrib\pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "D:\ANACONDA\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "D:\ANACONDA\lib\site-packages\OpenSSL\crypto.py", line 1550, in <module>
    class X509StoreFlags(object):
  File "D:\ANACONDA\lib\site-packages\OpenSSL\crypto.py", line 1570, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

这个报错似乎涉及到了模块之间的依赖关系问题。根据错误日志,它显示在导入OpenSSL模块时发生了错误。

为了解决这个问题,你可以尝试以下方法:

  1. 更新相关的库和依赖项:
pip install --upgrade cryptography pyopenssl

这将更新cryptographypyopenssl库,它们与OpenSSL密切相关。

  1. 卸载并重新安装OpenSSL:
  pip uninstall pyopenssl
   pip uninstall cryptography
   pip uninstall openssl

然后重新安装:

pip install pyopenssl cryptography
  1. 检查Python环境和库的一致性:
    确保你的Python环境和安装的库之间的版本兼容性良好。尽可能使用最新版本的Python和相关库。

如果问题仍然存在,可能需要检查其他依赖项和库之间的冲突,并尝试进一步的故障排除。笔记:在使用ModelScope中遇见相关依赖版本不兼容问题_第1张图片

你可能感兴趣的:(学习笔记,笔记,python,开发语言)