首页 > 解决方案 > 找不到名为“pyopengv”的模块

问题描述

我正在使用 Ubunutu LTS 18.04,并尝试为 python3 安装 OpenGV 模块。我已经从它的文档中克隆并构建了 OpenGV。我坐在python 3的标志上。我在文件夹/usr/local/lib/python3/dist-packages/中链接了pyopengv.cpython-36m-x86_64-linux-gnu.so。而且,它仍然不导入 pyopengv。我不明白出了什么问题。我将指定我在命令中所做的...

git clone https://github.com/laurentkneip/opengv

cd opengv

mkdir build && cd build && cmake .. && make

git submodule update --init --recursive

cmake .. -DBUILD_PYTHON=ON -DPYBIND11_PYTHON_VERSION=3.6 -DPYTHON_INSTALL_DIR=/usr/local/lib/python3.6/dist-packages

cd /usr/local/lib/python3.7/dist-packages/

ln -s /usr/local/lib/python3/dist-packages/pyopengv.cpython-36m-x86_64-linux-gnu.so

最后我在 opengv/python 中尝试这个 python3 tests.py ,但仍然得到“找不到模块 'pyopengv' 的错误。

任何人都知道我做错了什么?

标签: pythonlinuxcmake

解决方案


找不到名为“pyopengv”的模块

python3 tests.py将在中寻找 pyopengv/usr/lib/python3/dist-packages/

所以要么做,要么做cmake -DBUILD_PYTHON=ON -DPYBIND11_PYTHON_VERSION=3.6 -DPYTHON_INSTALL_DIR=/usr/lib/python3/dist-packages/ ..一个符号链接到所需的位置。

/usr/lib/python3/dist-packages/pyopengv.cpython-36m-x86_64-linux-gnu.so带有...测试的 Ubuntu 18.04

$ python3 tests.py 
Testing relative pose
Done testing relative pose
Testing relative pose ransac
Done testing relative pose ransac
Testing relative pose ransac rotation only
Done testing relative pose ransac rotation only
Testing triangulation
Done testing triangulation

编辑,2020 年 3 月 5 日

Ubuntu 18.04,完整的构建顺序:

git clone https://github.com/laurentkneip/opengv.git
cd opengv/
git submodule update --init --recursive
mkdir build && cd build/ 
cmake -DBUILD_PYTHON=ON -DPYBIND11_PYTHON_VERSION=3.6 -DPYTHON_INSTALL_DIR=/usr/lib/python3/dist-packages/ ..
make && sudo make install

检查模块位置:

find /usr/lib/ -name pyopengv.cpython-36m-x86_64-linux-gnu.so

/usr/lib/python3/dist-packages/pyopengv.cpython-36m-x86_64-linux-gnu.so

注意:检查“其他 Linux 操作系统”→ 可用模块位置是 /usr/lib64/python 3.6/site -packages


推荐阅读