它没有显示在pip list
zeke$ pip list | grep spacy
spacy (1.7.3)
如何获取模型的名称?
我试过了,但它没有用
echo "spaCy model:"
python3 -m sputnik --name spacy find
引发此错误:
zeke$ python3 -m sputnik --name spacy find
Traceback (most recent call last):
File "/Users/zeke/anaconda/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Users/zeke/anaconda/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/__main__.py", line 28, in <module>
main()
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/__main__.py", line 12, in main
args.run(args)
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/cli.py", line 89, in run
data_path=args.data_path)
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/__init__.py", line 114, in find
obj = cls(app_name, app_version, expand_path(data_path))
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/pool.py", line 19, in __init__
super(Pool, self).__init__(app_name, app_version, path, **kwargs)
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/package_list.py", line 33, in __init__
self.load()
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/package_list.py", line 51, in load
for package in self.packages():
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/package_list.py", line 47, in packages
yield self.__class__.package_class(path=os.path.join(self.path, path))
File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/package.py", line 15, in __init__
super(Package, self).__init__(defaults=meta['package'])
KeyError: 'package'
答案 0 :(得分:29)
自spaCy 1.7.0版起,sputnik
软件包管理器已弃用。在您的版本中,您应该能够使用spacy info
:
python -m spacy info # info about spaCy and installed models
python -m spacy info en # info about model with the shortcut link 'en'
所有模型元也作为meta
类的Language
属性公开,因此您可以在脚本中执行以下操作:
nlp = spacy.load('en') # or any other model
print(nlp.meta['name'])
如果您通过spaCy的新download
命令下载了模型,则它们将作为pip包安装。这意味着当您在同一环境中运行pip list
或pip freeze
时,它们会显示出来。
请注意,安装spaCy时不会自动下载模型,因此您必须单独下载它们(有关可用型号的列表,请参阅the docs):
python -m spacy download en # default English model (~50MB)
python -m spacy download en_core_web_md # larger English model (~1GB)