Python 安装hnswlib出错

Python 安装hnswlib出错解决办法

1.安装hnswlib出错

要使用hnswlib包来进行最邻近算法的运算,用pip方式安装hnswlib出现错误!

pip install hnswlib

在这里插入图片描述

2.解决办法

参考了网上其他的解决办法,方法如下:

2.1下载hnswlib包

电脑安装过git后,可以直接从cmd命令后下载hnswlib相关的包!

Github hnswlib地址

git clone https://github.com/nmslib/hnswlib.git
2.2下载pybind11包

pybind11 是一个轻量级的只包含一组头文件的 C++ 库,可以在 Python 中使用 C++ 类型。主要用于创建已有 C++ 代码的 Python 封装版本。其目的和语法类似于 Boost.Python 库。

pybind官网作用说明:

pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its goals and syntax are similar to the excellent Boost.Python library by David Abrahams: to minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection.

The main issue with Boost.Python—and the reason for creating such a similar project—is Boost. Boost is an enormously large and complex suite of utility libraries that works with almost every C++ compiler in existence. This compatibility has its cost: arcane template tricks and workarounds are necessary to support the oldest and buggiest of compiler specimens. Now that C++11-compatible compilers are widely available, this heavy machinery has become an excessively large and unnecessary dependency.

Think of this library as a tiny self-contained version of Boost.Python with everything stripped away that isn’t relevant for binding generation. Without comments, the core header files only require ~4K lines of code and depend on Python (2.7 or 3.5+, or PyPy) and the C++ standard library. This compact implementation was possible thanks to some of the new C++11 language features (specifically: tuples, lambda functions and variadic templates). Since its creation, this library has grown beyond Boost.Python in many ways, leading to dramatically simpler binding code in many common situations.

Tutorial and reference documentation is provided at pybind11.readthedocs.io. A PDF version of the manual is available here. And the source code is always available at github.com/pybind/pybind11.

使用pip的方式安装pybind11

pip install pybind11
2.3在hnswlib包进行操作

首先,进入hnswli包目录下
在这里插入图片描述

然后,进入cmd命令行该目录路径,执行以下命令
在这里插入图片描述

python setup.py install

结果:在这里插入图片描述

解决办法:

1.从此路径C:\Program Files (x86)\Windows Kits\8.1\bin\x86 目录下复制 rc.exe rcdll.dll

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

最后,安装成功!
在这里插入图片描述

3.结果

import hnswlib

在这里插入图片描述

hnswlib安装成功!

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值