KeyError: 'packaging' auto-fill the config file spacy BERT model

KeyError: 'packaging' auto-fill the config file spacy BERT model

我正在学习本教程 https://towardsdatascience.com/how-to-fine-tune-bert-transformer-with-spacy-3-6a90bfe57647 在我必须使用这个命令的部分

!python -m spacy init fill-config drive/MyDrive/config.cfg drive/MyDrive/config_spacy.cfg

我根据我的 colab 将路径修改为 运行 这个

!python -m spacy init fill-config "drive/MyDrive/EAD/for TL/base_config.cfg" "drive/MyDrive/EAD/for TL/config_spacy.cfg"

我有这个错误

Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/local/lib/python3.7/dist-packages/spacy/__init__.py", line 10, in <module>
    from thinc.api import prefer_gpu, require_gpu, require_cpu  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/thinc/__init__.py", line 5, in <module>
    from .config import registry
  File "/usr/local/lib/python3.7/dist-packages/thinc/config.py", line 14, in <module>
    import srsly
  File "/usr/local/lib/python3.7/dist-packages/srsly/__init__.py", line 4, in <module>
    from ._msgpack_api import read_msgpack, write_msgpack, msgpack_dumps, msgpack_loads
  File "/usr/local/lib/python3.7/dist-packages/srsly/_msgpack_api.py", line 3, in <module>
    from . import msgpack
  File "/usr/local/lib/python3.7/dist-packages/srsly/msgpack/__init__.py", line 13, in <module>
    from ._msgpack_numpy import encode_numpy as _encode_numpy
  File "/usr/local/lib/python3.7/dist-packages/srsly/msgpack/_msgpack_numpy.py", line 19, in <module>
    import cupy
  File "/usr/local/lib/python3.7/dist-packages/cupy/__init__.py", line 12, in <module>
    _environment._preload_libraries()  # NOQA
  File "/usr/local/lib/python3.7/dist-packages/cupy/_environment.py", line 286, in _preload_libraries
    if (config is None) or (config['packaging'] == 'conda'):
KeyError: 'packaging'

很抱歉你 运行,我们之前收到过一份关于该错误的报告。似乎 cupy 在 colab 上特别奇怪。基于 previous report,你应该从一个干净的 Python 环境开始,应该 直接安装 cupy。我认为colab使用特殊版本或其他东西。