如何在Windows 10上安装nmslib [英] How can I install nmslib on Windows 10

查看:299
本文介绍了如何在Windows 10上安装nmslib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用pip安装Scispacy,发现nmslib的安装引起了问题.互联网上有很多有关如何解决此问题的帖子,但似乎没有一个对我有用.

I am trying to install scispacy with pip and found that the installatio of nmslib was causing issues. There are various posts on the internet as to how to fix this, but none seem to be working for me.

我正在Windows 10笔记本电脑上运行Python 3.7.4 点是版本19.2.1

I am running Python 3.7.4 on a Windows 10 laptop Pip is version 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.

几周前,我遇到了同样的问题,在尝试过的上百万次尝试中,我能够使它正常工作,但是当时我还不确定我是如何做到的.我现在在新电脑上,问题不会消失.

A few weeks ago I had the same issue and amongst the million things I tried I was able to get it to work, but at the time I wasn't entirely sure how I did it. I'm now on a new computer and the issue won't go away.

推荐答案

nmslibc++库上的python包装器.因此,它可能会在少数系统上引起问题.我遇到了同样的问题.

nmslib is a python wrapper over a c++ library. Therefore it could cause problems on few systems. I had the same issue.

请从此处克隆存储库,然后手动安装,而不是pip安装.

Please clone the repository from here and install manually instead of the pip installation.

尝试以下操作之一.

  1. 根据此处的评论,nmslib是可选的并且仅在将其用于链接程序时才是必需的.因此,您可以从requirements.txt中对其进行注释,然后通过setup.py

  1. As per the comments from here,nmslib is optional and is only required if you use it for linker.So you may comment it from the requirements.txt and then do a manual installation via setup.py

在您的requirements.txt file顶部,添加numpy并通过setup.py文件安装.

In your requirements.txt file add numpy to the top and install via setup.py file.

尽管上述步骤可能会引发VC ++错误,但将安装scispacy模块,并且可以将其导入.

Though the above steps may throw a VC++ error, the scispacy module will get installed and you will be able to import it.

我尝试了两种解决方案,它们为我工作.

I tried both the solutions and they worked for me.

注意:另外,根据我的评论,我了解到,现在您可以直接使用spacy并加载scispacy模型,前提是您已经下载并安装了这些模型.

Note : Also, from the comments I understand that, now we may directly use spacy and load the scispacy models provided you have downloaded and installed the models.

pip install en_core_sci_sm
import spacy
nlp = spacy.load("en_core_sci_sm")

让我知道哪一个适合您.

Let me know which one works for you.

这篇关于如何在Windows 10上安装nmslib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆