pip - 如何在 Windows 10 上安装 nmslib
问题描述
我正在尝试使用 pip 安装 scispacy,发现 nmslib 的安装引起了问题。互联网上有很多关于如何解决这个问题的帖子,但似乎没有一个对我有用。
我在 Windows 10 笔记本电脑上运行 Python 3.7.4 Pip 版本为 19.2.1
这是日志的错误部分
2019-08-08T18:25:20,901 ERROR: Command errored out with exit status 1: 'c:\users\andre\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\andre\\AppData\\Local\\Temp\\pip-install-y6n2f026\\nmslib\\setup.py'"'"'; __file__='"'"'C:\\Users\\andre\\AppData\\Local\\Temp\\pip-install-y6n2f026\\nmslib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\andre\AppData\Local\Temp\pip-record-90f_5c93\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
2019-08-08T18:25:20,902 Exception information:
2019-08-08T18:25:20,902 Traceback (most recent call last):
2019-08-08T18:25:20,902 File "c:\users\andre\appdata\local\programs\python\python37\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in main
2019-08-08T18:25:20,902 status = self.run(options, args)
2019-08-08T18:25:20,902 File "c:\users\andre\appdata\local\programs\python\python37\lib\site-packages\pip\_internal\commands\install.py", line 407, in run
2019-08-08T18:25:20,902 use_user_site=options.use_user_site,
2019-08-08T18:25:20,902 File "c:\users\andre\appdata\local\programs\python\python37\lib\site-packages\pip\_internal\req\__init__.py", line 58, in install_given_reqs
2019-08-08T18:25:20,902 **kwargs
2019-08-08T18:25:20,902 File "c:\users\andre\appdata\local\programs\python\python37\lib\site-packages\pip\_internal\req\req_install.py", line 959, in install
2019-08-08T18:25:20,902 spinner=spinner,
2019-08-08T18:25:20,902 File "c:\users\andre\appdata\local\programs\python\python37\lib\site-packages\pip\_internal\utils\misc.py", line 934, in call_subprocess
2019-08-08T18:25:20,902 raise InstallationError(exc_msg)
2019-08-08T18:25:20,902 pip._internal.exceptions.InstallationError: Command errored out with exit status 1: 'c:\users\andre\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\andre\\AppData\\Local\\Temp\\pip-install-y6n2f026\\nmslib\\setup.py'"'"'; __file__='"'"'C:\\Users\\andre\\AppData\\Local\\Temp\\pip-install-y6n2f026\\nmslib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\andre\AppData\Local\Temp\pip-record-90f_5c93\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
几周前,我遇到了同样的问题,在我尝试的数百万种方法中,我能够让它工作,但当时我并不完全确定我是如何做到的。我现在在一台新电脑上,问题不会消失。
解决方案
nmslib
是一个c++
库的 python 包装器。因此,它可能会在少数系统上引起问题。我遇到过同样的问题。
请从这里克隆存储库并手动安装而不是pip
安装。
尝试以下方法之一。
根据此处的评论,
nmslib
是可选的,仅当您将其用于链接器时才需要。因此您可以从 requirements.txt 中对其进行评论,然后通过手动安装setup.py
或者
在您
requirements.txt file
添加numpy
到顶部并通过setup.py
文件安装。
虽然上述步骤可能会引发 VC++ 错误,但该scispacy
模块将被安装并且您将能够导入它。
我尝试了这两种解决方案,它们对我有用。
注意:另外,从评论中我了解到,如果您已经下载并安装了模型,现在我们可以直接使用spacy
和加载scispacy
模型。
pip install en_core_sci_sm
import spacy
nlp = spacy.load("en_core_sci_sm")
让我知道哪一个适合你。
推荐阅读
- c# - 从 Bootstrap 模式弹出窗口提交数据
- ruby-on-rails - 尝试从 API 获取 JSON 数据时出现 No such file or directory 错误?
- javascript - 如何翻转 div 的内容?(底部的元素变成顶部的元素)
- r - 如何根据特定条件删除 R 中的行
- python - 使用 h5py 过滤 hdf5 文件中的组
- angular - 在 url 上隐藏参数的最佳做法是什么
- firebase - 跟踪集合中文档的计数器变量的最佳方法
- excel - 基于使用 OR 运算符给出错误结果的条件的平均值
- css - NGINX服务器debian 8中的CSS问题
- java - Java 类异常未按预期工作