我已经安装了俄语模型,但无法加载。
安装:
(tf2) C:\Windows\System32\spacy-ru>pip install git+https://github.com/buriy/spacy-ru
Collecting git+https://github.com/buriy/spacy-ru
Cloning https://github.com/buriy/spacy-ru to c:\users\alienware\appdata\local\temp\pip-req-build-x7fqevak
Running command git clone -q https://github.com/buriy/spacy-ru 'C:\Users\Alienware\AppData\Local\Temp\pip-req-build-x7fqevak'
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: pymorphy2>=0.8 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy-ru==0.1.0) (0.8)
Requirement already satisfied: spacy>=2.0 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy-ru==0.1.0) (2.2.3)
Requirement already satisfied: docopt>=0.6 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from pymorphy2>=0.8->spacy-ru==0.1.0) (0.6.2)
Requirement already satisfied: pymorphy2-dicts<3.0,>=2.4 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from pymorphy2>=0.8->spacy-ru==0.1.0) (2.4.393442.3710985)
Requirement already satisfied: dawg-python>=0.7 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from pymorphy2>=0.8->spacy-ru==0.1.0) (0.7.2)
Requirement already satisfied: setuptools in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (42.0.2.post20191203)
Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (0.4.2)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (0.4.1)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (2.0.2)
Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (0.0.8)
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (3.0.2)
Requirement already satisfied: srsly<1.1.0,>=0.1.0 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (0.2.0)
Requirement already satisfied: plac<1.2.0,>=0.9.6 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (0.9.6)
Requirement already satisfied: numpy>=1.15.0 in c:\users\alienware\appdata\roaming\python\python37\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (1.16.5)
Requirement already satisfied: thinc<7.4.0,>=7.3.0 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (7.3.1)
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (1.0.2)
Requirement already satisfied: requests<3.0.0,>=2.13.0 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from spacy>=2.0->spacy-ru==0.1.0) (2.22.0)
Requirement already satisfied: importlib-metadata>=0.20; python_version < "3.8" in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from catalogue<1.1.0,>=0.0.7->spacy>=2.0->spacy-ru==0.1.0) (1.3.0)
Requirement already satisfied: tqdm<5.0.0,>=4.10.0 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from thinc<7.4.0,>=7.3.0->spacy>=2.0->spacy-ru==0.1.0) (4.41.0)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\alienware\appdata\roaming\python\python37\site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.0->spacy-ru==0.1.0) (2.6)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.0->spacy-ru==0.1.0) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\alienware\appdata\roaming\python\python37\site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.0->spacy-ru==0.1.0) (1.22)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.0->spacy-ru==0.1.0) (2019.11.28)
Requirement already satisfied: zipp>=0.5 in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from importlib-metadata>=0.20; python_version < "3.8"->catalogue<1.1.0,>=0.0.7->spacy>=2.0->spacy-ru==0.1.0) (0.6.0)
Requirement already satisfied: more-itertools in c:\users\alienware\anaconda3\envs\tf2\lib\site-packages (from zipp>=0.5->importlib-metadata>=0.20; python_version < "3.8"->catalogue<1.1.0,>=0.0.7->spacy>=2.0->spacy-ru==0.1.0) (8.0.2)
Building wheels for collected packages: spacy-ru
Building wheel for spacy-ru (PEP 517) ... done
Created wheel for spacy-ru: filename=spacy_ru-0.1.0-cp37-none-any.whl size=6988 sha256=15d68b6e73a84c9ef69648e2e8508a4abc8d88429012001ccecc5b14bcd8d0d8
Stored in directory: C:\Users\Alienware\AppData\Local\Temp\pip-ephem-wheel-cache-v9egaxz3\wheels\db\d9\df\ad5eaf2716070c05b5b570e9625d36a471527e01e7e0c60e8b
Successfully built spacy-ru
Installing collected packages: spacy-ru
Successfully installed spacy-ru-0.1.0
但是当我尝试加载它时,出现异常:
import spacy
nlp = spacy.load('ru2')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-3-d0717a339da8> in <module>
1 import spacy
2
----> 3 nlp = spacy.load('ru2')
~\Anaconda3\envs\tf2\lib\site-packages\spacy\__init__.py in load(name, **overrides)
28 if depr_path not in (True, False, None):
29 deprecation_warning(Warnings.W001.format(path=depr_path))
---> 30 return util.load_model(name, **overrides)
31
32
~\Anaconda3\envs\tf2\lib\site-packages\spacy\util.py in load_model(name, **overrides)
167 elif hasattr(name, "exists"): # Path or Path-like to model data
168 return load_model_from_path(name, **overrides)
--> 169 raise IOError(Errors.E050.format(name=name))
170
171
OSError: [E050] Can't find model 'ru2'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
您有什么建议?
答案 0 :(得分:0)
您需要在使用之前在本地安装模型,例如
my_task = AsyncResult(my_task_id, app=my_app)
print(my_task.status)