mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 09:14:32 +03:00
Require downloaded model in pkg_resources (#4090)
This commit is contained in:
parent
8b4a0fabbb
commit
6bec24cdd0
|
@ -6,6 +6,7 @@ import requests
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import pkg_resources
|
||||
from wasabi import Printer
|
||||
|
||||
from .link import link
|
||||
|
@ -67,6 +68,16 @@ def download(model, direct=False, *pip_args):
|
|||
"the model via its full package name: "
|
||||
"nlp = spacy.load('{}')".format(model, model_name),
|
||||
)
|
||||
# If a model is downloaded and then loaded within the same process, our
|
||||
# is_package check currently fails, because pkg_resources.working_set
|
||||
# is not refreshed automatically (see #3923). We're trying to work
|
||||
# around this here be requiring the package explicitly.
|
||||
try:
|
||||
pkg_resources.working_set.require(model_name)
|
||||
except: # noqa: E722
|
||||
# Maybe it's possible to remove this – mostly worried about cross-
|
||||
# platform and cross-Python copmpatibility here
|
||||
pass
|
||||
|
||||
|
||||
def get_json(url, desc):
|
||||
|
|
Loading…
Reference in New Issue
Block a user