Open varun19299 opened 5 years ago
The same question as yours, did you find any solutions?
Installing with sudo (I was okay with that since I was using it in a container) seemed to work.
Naturally that would be in the system python. I don't quite understand the issue though? Do some modules under the Cmake file have permission requirements?
hi everybody, @Haotian-Zhang. did you solve this issue? I am still on error.
AttributeError: module 'g2o' has no attribute 'BlockSolverSE3'
I solved my problem. I was trying to install on python 3.6... it doesn't work. I installed on python 3.5.2 I installed in the default python3 of UBUNTU 16.04.
python3 setup.py install
I also created a conda env.
conda create -n g2o_env python=3.5.2
conda activate g2o_env
conda python setup.py install
Remember that setup.py script is under the directory project....
Installing g2opy
under sudo
worked for me.
Yeah but that isn't a recommended way
For some reason, g2opy is creating a python3.7 library. If I create a virtualenv with python3.7, I am able to use it. The generated so file is called g2o.cpython-37m-x86_64-linux-gnu.so
. How do I force g2opy to compile with 3.6 or any arbitrary python version?
(Also, renaming g2o.cpython-37m-x86_64-linux-gnu.so
to g2o.cpython-36m-x86_64-linux-gnu.so
gives an import error for the version mismatch)
I install g2opy with sudo ,but it doesn't work either...
For those having the same problem, first don't run any export PYTHON_PATH=PATH-to-g2o/g2o:$PYTHONPATH
because the g2o
folder is written in C++ and not what you want.
As discussed here, you need to build for the python version you're using. Remove the build
folder and re-run cmake with:
cmake -DPYBIND11_PYTHON_VERSION=3.6 ..
make -j8
which will create g2o.cpython-36m-x86_64-linux-gnu.so
in the /lib folder (instead of 37m
). Finally, make sure that there is only one g2o*.so
file in the /lib folder before running python setup.
@minhkhang1795 @varun19299 @EnriqueSolarte This is due to the fact the External/pybind11/CMakeLists.txt computed wrong version of python.
After some modification you can get correction python library with correct extension name:
yiakwy@yiakwy ~/WorkSpace/Github/g2opy/build master ●
cmake ..
-- Compiling on Unix
-- Found CHOLMOD and its dependencies
-- Building LGPL code as static library (affects license of the binary)
-- Compiling with OpenGL support
-- Could NOT find QGLVIEWER (missing: QGLVIEWER_INCLUDE_DIR QGLVIEWER_LIBRARY)
-- Compiling with GCC
-- pybind11 PYTHON_INCLUDE_DIR: /home/yiakwy/anaconda3/envs/py36/include/python3.6m
-- pybind11 PYTHON_LIBRARY: /home/yiakwy/anaconda3/envs/py36/lib/libpython3.6m.so.1.0
-- PYTHON_MODULE_PREFIX: /home/yiakwy/anaconda3/envs/py36
-- PYTHON_MODULE_EXTENSION: .cpython-36m-x86_64-linux-gnu.so
-- pybind11 v2.2.1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yiakwy/WorkSpace/Github/g2opy/build
...
[ 99%] Linking CXX shared module ../../lib/g2o.cpython-36m-x86_64-linux-gnu.so
...
[100%] Built target g2o
Pybind11 will generate correct library for corresponding python executables. Using sudo is prohibited because it will use system installed python which will creates global conflicts later.
@minhkhang1795 @uoip I have to see scripts of External/pybind11/CMakeLists.txt only to find that they are messed up the real python package used in the project.
The author wanted to use "PYTHON_BUILD_MODULE" but it actually sets to "" and moreover, setting these variables in "External/pybind11/CMakeLists.txt" in child scope makes no effects on "python/CMakeLists.txt" .
These two mistakes lead to wrong configuration for python!
Installed on
python 3.6
, anaconda. Built g2o successfully.Ran :
export PYTHON_PATH=PATH-to-g2o/g2o:$PYTHONPATH
.Able to import g2o, but only private modules found. Unable to use
g2o.SparseOptimizer
.