Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only private modules found #15

Open
varun19299 opened this issue Oct 31, 2018 · 10 comments
Open

Only private modules found #15

varun19299 opened this issue Oct 31, 2018 · 10 comments

Comments

@varun19299
Copy link

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.

Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import g2o
>>> g2o.__
g2o.__class__(         g2o.__dir__(           g2o.__format__(        g2o.__gt__(            g2o.__le__(            g2o.__name__           g2o.__package__        g2o.__reduce_ex__(     g2o.__sizeof__(        g2o.__subclasshook__(
g2o.__delattr__(       g2o.__doc__            g2o.__ge__(            g2o.__hash__(          g2o.__loader__         g2o.__ne__(            g2o.__path__           g2o.__repr__(          g2o.__spec__
g2o.__dict__           g2o.__eq__(            g2o.__getattribute__(  g2o.__init__(          g2o.__lt__(            g2o.__new__(           g2o.__reduce__(        g2o.__setattr__(       g2o.__str__(
@Haotian-Zhang
Copy link

The same question as yours, did you find any solutions?

@varun19299
Copy link
Author

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?

@EnriqueSolarte
Copy link

hi everybody,
@Haotian-Zhang. did you solve this issue? I am still on error.

AttributeError: module 'g2o' has no attribute 'BlockSolverSE3'

@EnriqueSolarte
Copy link

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....

@shakhrayv
Copy link

shakhrayv commented Apr 17, 2019

Installing g2opy under sudo worked for me.

@varun19299
Copy link
Author

Yeah but that isn't a recommended way

@medakk
Copy link

medakk commented Apr 24, 2019

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)

@kaixinbear
Copy link

I install g2opy with sudo ,but it doesn't work either...

@minhkhang1795
Copy link

minhkhang1795 commented Mar 5, 2020

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.

@yiakwy-enterprise-roborock
Copy link

yiakwy-enterprise-roborock commented Apr 15, 2020

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants