WXL's blog

Talk is cheap, show me your work.

0%

安装lapsolver

记录安装lapsolver的步骤。

windows

首先安装cmake:

1
pip install cmake

因为我使用的是python3.7,所以无法直接使用pip install lapsolver。需要从源码安装,首先将仓库代码克隆过来:

1
git clone --recursive https://github.com/cheind/py-lapsolver.git

build project:

1
python setup.py develop

接下来,如果按照步骤应该执行下面指令:

1
python setup.py test

但是我在执行的时候报错说pytest版本的问题:

我继续执行了如下代码,发现可以正常使用:

1
2
3
4
5
6
7
8
9
10
11
12
13
import numpy as np
from lapsolver import solve_dense

costs = np.array([
[6, 9, 1],
[10, 3, 2],
[8, 7, 4.]
], dtype=np.float32)

rids, cids = solve_dense(costs)

for r,c in zip(rids, cids):
print(r,c) # Row/column pairings

参考:

https://libraries.io/pypi/lapsolver

https://blog.csdn.net/Moluth/article/details/88738930

行行好,赏一杯咖啡吧~