即使我下载了该模型,也无法加载
[jalal@goku entity-sentiment-analysis]$ which python
/scratch/sjn/anaconda/bin/python
[jalal@goku entity-sentiment-analysis]$ sudo python -m spacy download en
[sudo] password for jalal:
Collecting https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz
Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz (37.4MB)
100% |████████████████████████████████| 37.4MB 9.4MB/s
Installing collected packages: en-core-web-sm
Running setup.py install for en-core-web-sm ... done
Successfully installed en-core-web-sm-2.0.0
Linking successful
/usr/lib/python2.7/site-packages/en_core_web_sm -->
/usr/lib64/python2.7/site-packages/spacy/data/en
You can now load the model via spacy.load('en')
import spacy
nlp = spacy.load('en')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-0fcabaab8c3d> in <module>()
1 import spacy
2
----> 3 nlp = spacy.load('en')
/scratch/sjn/anaconda/lib/python3.6/site-packages/spacy/__init__.py in load(name, **overrides)
17 "to load. For example:nnlp = spacy.load('{}')".format(depr_path),
18 'error')
---> 19 return util.load_model(name, **overrides)
20
21
/scratch/sjn/anaconda/lib/python3.6/site-packages/spacy/util.py in load_model(name, **overrides)
118 elif hasattr(name, 'exists'): # Path or Path-like to model data
119 return load_model_from_path(name, **overrides)
--> 120 raise IOError("Can't find model '%s'" % name)
121
122
OSError: Can't find model 'en'
我应该如何解决此问题?
如果我不使用sudo下载en型号,我会得到:
Collecting https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz
Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz (37.4MB)
100% |████████████████████████████████| 37.4MB 9.6MB/s ta 0:00:011 62% |████████████████████ | 23.3MB 8.6MB/s eta 0:00:02
Requirement already satisfied (use --upgrade to upgrade): en-core-web-sm==2.0.0 from https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz in /scratch/sjn/anaconda/lib/python3.6/site-packages
You are using pip version 10.0.0, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Error: Couldn't link model to 'en'
Creating a symlink in spacy/data failed. Make sure you have the required
permissions and try re-running the command as admin, or use a
virtualenv. You can still import the model as a module and call its
load() method, or create the symlink manually.
/scratch/sjn/anaconda/lib/python3.6/site-packages/en_core_web_sm -->
/scratch/sjn/anaconda/lib/python3.6/site-packages/spacy/data/en
Download successful but linking failed
Creating a shortcut link for 'en' didn't work (maybe you don't have
admin permissions?), but you can still load the model via its full
package name:
nlp = spacy.load('en_core_web_sm')
最终清除了错误!
现在安装的最佳方法
pip install -U pip setuptools wheel
pip install -U spacy
python -m spacy download en_core_web_sm
始终打开Anaconda提示/命令提示
尝试了多个选项,包括:
python -m spacy download en
conda install -c conda-forge spacy
python -m spacy download en_core_web_sm
python -m spacy link en_core_web_sm en
无效,因为我使用我的公司的网络。最后,此命令像魅力一样工作: - (
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz --no-deps
- 使用最新链接更新:
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz --no-deps
感谢更新的github链接: - (
通过使用sudo python ...
,您可以安装与本地解释器不同的Python解释器。实际上,它在您的日志中说,Spacy模型已安装到/usr/lib64/python2.7/site-packages/
而不是/scratch/sjn/anaconda/lib/python3.6/site-packages/
。
尝试运行python -m spacy download en
,并应将模型安装到正确的目录。
1(安装spacy
$ python -m spacy download en
2(安装模型en_core_web_sm
$ python -m spacy download en_core_web_sm
>>> import spacy
>>> nlp = spacy.load("en_core_web_sm")
哦。事实证明,即使我的python显示了Anaconda Python,当我使用Python下载时,它将其链接到我的机器上的Python2.7本地。我使用以下命令修复了它:
$ sudo /scratch/sjn/anaconda/bin/python -m spacy download en
我正在使用anaconda jupyter笔记本电脑,并且出现同样的错误。在Anaconda提示(作为管理员运行(中运行以下命令,并解决了我的问题:
(base) C:WINDOWSsystem32>conda install -c conda-forge spacy
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:UsersyadavAnaconda3
added / updated specs:
- spacy
The following packages will be downloaded:
package | build
---------------------------|-----------------
cymem-2.0.3 | py37h6538335_0 35 KB conda-forge
cython-blis-0.4.1 | py37hfa6e2cd_0 4.3 MB conda-forge
murmurhash-1.0.0 | py37h6538335_0 17 KB conda-forge
plac-0.9.6 | py_1 18 KB conda-forge
preshed-3.0.2 | py37h6538335_1 89 KB conda-forge
spacy-2.2.1 | py37he980bc4_0 7.4 MB conda-forge
srsly-0.2.0 | py37h6538335_0 189 KB conda-forge
thinc-7.1.1 | py37he980bc4_0 1.4 MB conda-forge
wasabi-0.4.0 | py_0 19 KB conda-forge
------------------------------------------------------------
Total: 13.4 MB
The following NEW packages will be INSTALLED:
cymem conda-forge/win-64::cymem-2.0.3-py37h6538335_0
cython-blis conda-forge/win-64::cython-blis-0.4.1-py37hfa6e2cd_0
murmurhash conda-forge/win-64::murmurhash-1.0.0-py37h6538335_0
plac conda-forge/noarch::plac-0.9.6-py_1
preshed conda-forge/win-64::preshed-3.0.2-py37h6538335_1
spacy conda-forge/win-64::spacy-2.2.1-py37he980bc4_0
srsly conda-forge/win-64::srsly-0.2.0-py37h6538335_0
thinc conda-forge/win-64::thinc-7.1.1-py37he980bc4_0
wasabi conda-forge/noarch::wasabi-0.4.0-py_0
Proceed ([y]/n)? Y
Downloading and Extracting Packages
cython-blis-0.4.1 | 4.3 MB | ############################################################################ | 100%
cymem-2.0.3 | 35 KB | ############################################################################ | 100%
srsly-0.2.0 | 189 KB | ############################################################################ | 100%
thinc-7.1.1 | 1.4 MB | ############################################################################ | 100%
plac-0.9.6 | 18 KB | ############################################################################ | 100%
spacy-2.2.1 | 7.4 MB | ############################################################################ | 100%
preshed-3.0.2 | 89 KB | ############################################################################ | 100%
wasabi-0.4.0 | 19 KB | ############################################################################ | 100%
murmurhash-1.0.0 | 17 KB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base) C:WINDOWSsystem32>python -m spacy download en
Collecting en_core_web_sm==2.2.0
Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz (12.0MB)
|████████████████████████████████| 12.0MB 409kB/s
Requirement already satisfied: spacy>=2.2.0 in c:usersyadavanaconda3libsite-packages (from en_core_web_sm==2.2.0) (2.2.2)
Requirement already satisfied: numpy>=1.15.0 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (1.16.2)
Requirement already satisfied: thinc<7.4.0,>=7.3.0 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (7.3.1)
Requirement already satisfied: wasabi<1.1.0,>=0.3.0 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (0.4.0)
Requirement already satisfied: requests<3.0.0,>=2.13.0 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (2.21.0)
Requirement already satisfied: setuptools in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (40.8.0)
Requirement already satisfied: plac<1.2.0,>=0.9.6 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (1.1.3)
Requirement already satisfied: srsly<1.1.0,>=0.1.0 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (0.2.0)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (2.0.3)
Requirement already satisfied: importlib-metadata>=0.20; python_version < "3.8" in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (0.23)
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (1.0.2)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (0.4.1)
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in c:usersyadavanaconda3libsite-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (3.0.2)
Requirement already satisfied: tqdm<5.0.0,>=4.10.0 in c:usersyadavanaconda3libsite-packages (from thinc<7.4.0,>=7.3.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (4.36.1)
Requirement already satisfied: certifi>=2017.4.17 in c:usersyadavanaconda3libsite-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (2019.3.9)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:usersyadavanaconda3libsite-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (1.24.1)
Requirement already satisfied: idna<2.9,>=2.5 in c:usersyadavanaconda3libsite-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:usersyadavanaconda3libsite-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (3.0.4)
Requirement already satisfied: zipp>=0.5 in c:usersyadavanaconda3libsite-packages (from importlib-metadata>=0.20; python_version < "3.8"->spacy>=2.2.0->en_core_web_sm==2.2.0) (0.6.0)
Requirement already satisfied: more-itertools in c:usersyadavanaconda3libsite-packages (from zipp>=0.5->importlib-metadata>=0.20; python_version < "3.8"->spacy>=2.2.0->en_core_web_sm==2.2.0) (6.0.0)
Building wheels for collected packages: en-core-web-sm
Building wheel for en-core-web-sm (setup.py) ... done
Created wheel for en-core-web-sm: filename=en_core_web_sm-2.2.0-cp37-none-any.whl size=12019131 sha256=f716e80f029462a80e9fb79ef353c1ac8c0f81d3754778bb6fec520d640fcc87
Stored in directory: C:UsersyadavAppDataLocalTemppip-ephem-wheel-cache-bvy0x0egwheels485c1c15f9d02afc8221a668d2172446dd8467b20cdb9aef80a172a4
Successfully built en-core-web-sm
Installing collected packages: en-core-web-sm
Found existing installation: en-core-web-sm 2.0.0
Uninstalling en-core-web-sm-2.0.0:
Successfully uninstalled en-core-web-sm-2.0.0
Successfully installed en-core-web-sm-2.2.0
✔ Download and installation successful
You can now load the model via spacy.load('en_core_web_sm')
symbolic link created for C:UsersyadavAnaconda3libsite-packagesspacydataen <<===>> C:UsersyadavAnaconda3libsite-packagesen_core_web_sm
✔ Linking successful
C:UsersyadavAnaconda3libsite-packagesen_core_web_sm -->
C:UsersyadavAnaconda3libsite-packagesspacydataen
You can now load the model via spacy.load('en')
(base) C:WINDOWSsystem32>
然后在jupyter笔记本中加载,如下所示:
nlp = spacy.load('en',parse=True,tag=True, entity=True)
如果使用其他python版本,则可以运行:
sudo python3.6 -m spacy下载
和我,我的版本3.6我希望它可以帮助您的问题!
当您使用anaconda时,打开Anaconda提示为管理员并执行以下命令
python -m spacy download en
在jupyter笔记本中加载spacy'en'使用以下命令
spacy.load('en')
- 您需要下载
en_core_web_sm
- 如果您使用的是
anaconda
,请运行此命令 -
conda install -c conda-forge spacy-model-en_core_web_sm
- 并将其加载为
-
nlp= spacy.load('en_core_web_sm')
bc我在这里没有找到我的错误(适用于使用jupyter笔记本,Alteryx,公司网络并且有此错误的每个人(:
我尝试使用Python创建一个宏来进行主题检测,但错误的错误是没有一个名为" en_core_web_sm"的模块
开始在开始时安装以下包装,并进行以下代码:
来自Ayx Import软件包package.installpackages(['pandas','numpy','matplotlib', " Gensim"," Spacy"," Pyldavis", 'https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz']((
,如果您引用了模块的使用:
导入en_core_web_sm
nlp = en_core_web_sm.load((
为我工作perf fine:(
转到https://github.com/explosion/spacy-models
下载要在Spacy中加载的型号
将下载的文件粘贴在Anaconda文件夹中的Spacy文件夹中
在那里打开CMD。键入以下命令并点击输入:
pip install en_core_web_md-1.2.0.tar.gz
上述命令可能会根据下载的文件的版本而有所不同。
瞧!错误已经消失:(
pip install https://github.com/explosion/spacy-
models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz
#fixes an permission error when attempting to create the symlinks on windows 10
python -m spacy link en_core_web_sm en_core_web_smc
from Jupyter notes
import spacy
nlp = spacy.load('en_core_web_sm')
由于您使用的是python版本3.6,请尝试使用 -
python3 -m spacy下载
而不仅仅是python -m .....
如果您已经下载了Spacy和语言模型(例如en_core_web_sm或en_core_web_md(,则可以按照以下步骤操作:
-
打开Anaconda提示为Admin
-
然后类型:python -m spacy链接[软件包名称或路径] [快捷方式]
用于例如Python -M Spacy链接/用户/您/模型EN
这将为您的语言模型创建一个符号链接。现在,您可以在笔记本或脚本中使用spacy.load('en&quot(加载模型
快速修复:安装可用模型(例如en_core_web_sm(,然后自己制作符号链接。复制两条路径Spacy说它无法链接(可能是由于没有管理高程的虚拟环境而引起的(并使用例如。Windows上的mklink。
例如。mklink /D C:UsersUSERPROJECTvenv2libsite-packagesspacydataen C:UsersUSERPROJECTvenv2libsite-packagesen_core_web_sm