【问题标题】:No module named 'pyopengv' found找不到名为“pyopengv”的模块
【发布时间】:2020-03-04 14:30:17
【问题描述】:

我正在使用 Ubunutu LTS 18.04,并尝试为 python3 安装 OpenGV 模块。 我已经从它的文档中克隆并构建了 OpenGV。我坐在 python 3 的标志上。我将 pyopengv.cpython-36m-x86_64-linux-gnu.so 链接到文件夹 /usr/local/lib/python3/dist-packages/ 中。 而且,它仍然不导入 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'的错误。

有人知道我做错了什么吗?

【问题讨论】:

  • 你用的是哪个python,3.6还是3.7?另外,ln -s 不接受 两个 参数吗?
  • 我不知道所有的ln 实现,但在 Ubuntu 18.04 上看起来ln -s 将默认第二个参数为./
  • 至于ln,就像shay说的那样。我最后可以写.,也可以不写。至于 python 版本,我实际上在几分钟前就注意到了一些事情。我应该使用 3.6 .. 但后来我有了 anaconda,我认为它使用的是 3.7,它安装了 3.7 的模块。我不知道。我认为 pip 和 anaconda 以及不同版本的 python 有问题。我该如何解决?我正在考虑重新安装它,但要完全删除 py3.6 和 pip。

标签: python linux cmake


【解决方案1】:

找不到名为“pyopengv”的模块

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

所以要么使用cmake -DBUILD_PYTHON=ON -DPYBIND11_PYTHON_VERSION=3.6 -DPYTHON_INSTALL_DIR=/usr/lib/python3/dist-packages/ ..,要么创建一个指向所需位置的符号链接。

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

$ 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/python3.6/site-packages

【讨论】:

  • 我尝试了cmake -DBUILD_PYTHON=ON -DPYBIND11_PYTHON_VERSION=3.6 -DPYTHON_INSTALL_DIR=/usr/lib/python3/dist-packages/ .. ,然后运行 ​​python3 tests.py 仍然是一样的东西。没有名为“pyopengv”的模块。
  • 您能否在问题本身中查看我上面的评论?如果它可以显示任何有用的东西......
  • 模块被删除了......我做了第二个'make install':同样的结果。 (请参阅编辑后的答案。)
  • 我现在正在尝试。抱歉我回复晚了。顺便说一句,我将命令中的 Python 版本从 3. 更改为 3.7,因为这是我使用命令 python -V 时识别的版本
  • 不幸的是相同的输出。 :(
猜你喜欢
  • 2019-08-26
  • 2012-05-26
  • 1970-01-01
  • 1970-01-01
  • 2018-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-16
相关资源
最近更新 更多