【问题标题】:ValueError with NERDA model importNERDA 模型导入的 ValueError
【发布时间】:2021-08-25 21:31:58
【问题描述】:

我正在尝试导入 NERDA 库,以便使用它来参与 Python 中的命名实体识别任务。我最初尝试在 jupyter notebook 中导入库并收到以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\NERDA\models.py", line 13, in <module>
    from .networks import NERDANetwork
  File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\NERDA\networks.py", line 4, in <module>
    from transformers import AutoConfig
  File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\transformers\__init__.py", line 43, in <module>
    from . import dependency_versions_check
  File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\transformers\dependency_versions_check.py", line 36, in <module>
    from .file_utils import is_tokenizers_available
  File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\transformers\file_utils.py", line 51, in <module>
    from huggingface_hub import HfApi, HfFolder, Repository
  File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\huggingface_hub\__init__.py", line 31, in <module>
    from .file_download import cached_download, hf_hub_url
  File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\huggingface_hub\file_download.py", line 37, in <module>
    if tuple(int(i) for i in _PY_VERSION.split(".")) < (3, 8, 0):
  File "C:\Users\oefel\AppData\Local\Programs\Python\Python38\lib\site-packages\huggingface_hub\file_download.py", line 37, in <genexpr>
    if tuple(int(i) for i in _PY_VERSION.split(".")) < (3, 8, 0):
ValueError: invalid literal for int() with base 10: '6rc1'

然后我尝试在 gitbash 中使用 pip 进行全局安装并得到同样的错误。该库似乎安装没有错误,但是当我尝试以下导入时,我得到相同的 ValueError:

from NERDA.models import NERDA

我还尝试了一些预煮模型导入并得到相同的 ValueError。

from NERDA.precooked import EN_ELECTRA_EN
from NERDA.precooked import EN_BERT_ML

我在网上找不到有关此错误的任何信息,希望有人能提供一些见解?非常感谢!

【问题讨论】:

    标签: python huggingface-transformers named-entity-recognition


    【解决方案1】:

    看看source code of the used huggingface_hub lib。他们比较您的 python 版本以执行不同的导入。
    但是您使用了release candidate python 版本(这告诉了导致错误的值'6rc1')。因为他们没有预料到/没有处理这个,所以你得到了 int-parse-ValueError。


    解决方案 1:
    将您的 python 版本更新为稳定版本。没有候选版本。所以你有一个仅 int 的版本号。

    解决方案 2:
    Monkeypatch sys.version,在您导入 NERDA 库之前。

    sys.version = '3.8.0'
    

    【讨论】:

    • 非常感谢!我采用了您的第二个解决方案,并且成功了。真的很感谢@Sven!
    猜你喜欢
    • 2020-08-15
    • 2013-04-05
    • 1970-01-01
    • 2015-07-11
    • 2012-02-04
    • 2017-09-29
    • 2019-06-15
    • 1970-01-01
    • 2018-02-23
    相关资源
    最近更新 更多