8000 python-install fails because of stubgen: · Issue #167 · borglab/wrap · GitHub
[go: up one dir, main page]

Skip to content

python-install fails because of stubgen: #167

Open

Description

@dellaert

I am in a python3 conda environment, on MacOS 14.6.1,

(py310) (base) macbook-pro-8:build dellaert$ python --version
Python 3.10.14

Traceback (most recent call last):
  File "/Users/dellaert/miniforge3/envs/py310/bin/pybind11-stubgen", line 8, in <module>
    sys.exit(main())
  File "/Users/dellaert/miniforge3/envs/py310/lib/python3.10/site-packages/pybind11_stubgen/__init__.py", line 319, in main
    run(
  File "/Users/dellaert/miniforge3/envs/py310/lib/python3.10/site-packages/pybind11_stubgen/__init__.py", line 358, in run
    QualifiedName.from_str(module_name), importlib.import_module(module_name)
  File "/Users/dellaert/miniforge3/envs/py310/lib/python3.10/importlib/__init__.py", line 126, in import_module
Traceback (most recent call last):
    return _bootstrap._gcd_import(name[level:], package, level)  File "/Users/dellaert/miniforge3/envs/py310/bin/pybind11-stubgen", line 8, in <module>

  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    sys.exit(main())
  File "/Users/dellaert/miniforge3/envs/py310/lib/python3.10/site-packages/pybind11_stubgen/__init__.py", line 319, in main
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
    run(
  File "/Users/dellaert/miniforge3/envs/py310/lib/python3.10/site-packages/pybind11_stubgen/__init__.py", line 358, in run
  File "/Users/dellaert/git/github/build/python/gtsam_unstable/__init__.py", line 1, in <module>
    QualifiedName.from_str(module_name), importlib.import_module(module_name)
  File "/Users/dellaert/miniforge3/envs/py310/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
    from .gtsam_unstable import *
ModuleNotFoundError: No module named 'gtsam_unstable.gtsam_unstable'
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/dellaert/git/github/build/python/gtsam/__init__.py", line 9, in <module>
    from gtsam import gtsam, utils
ImportError: cannot import name 'gtsam' from partially initialized module 'gtsam' (most likely due to a circular import) (/Users/dellaert/git/github/build/python/gtsam/__init__.py)
make[3]: *** [python/CMakeFiles/python-unstable-stubs] Error 1
make[3]: *** [python/CMakeFiles/python-stubs] Error 1
make[2]: *** [python/CMakeFiles/python-unstable-stubs.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [python/CMakeFiles/python-stubs.dir/all] Error 2
make[1]: *** [python/CMakeFiles/python-install.dir/rule] Error 2
make: *** [python-install] Error 2

Activity

  1. dellaert commented on Sep 20, 2024

    @dellaert
    MemberAuthor

    Actually, even after disabling the stub generation, the library installs fine but the same circular import issue remains:

    (py310) (base) macbook-pro-8:github dellaert$ /Users/dellaert/miniforge3/envs/py310/bin/python /Users/dellaert/git/github/python/gtsam/tests/test_Pose3.py
    Traceback (most recent call last):
      File "/Users/dellaert/git/github/python/gtsam/tests/test_Pose3.py", line 16, in <module>
        from gtsam.utils.test_case import GtsamTestCase
      File "/Users/dellaert/.local/lib/python3.10/site-packages/gtsam/__init__.py", line 9, in <module>
        from gtsam import gtsam, utils
    ImportError: cannot import name 'gtsam' from partially initialized module 'gtsam' (most likely due to a circular import) (/Users/dellaert/.local/lib/python3.10/site-packages/gtsam/__init__.py)
    

    Did something about this change in the last PRs? It's weird as it still works in CI. I remember that this circular thing was an issue a long time ago, but it's weird it pops up again now.

  2. dellaert commented on Sep 20, 2024

    @dellaert
    MemberAuthor
    ls /Users/dellaert/.local/lib/python3.10/site-packages/gtsam
    Data				examples			imuBias.py			tests
    __init__.py			gtsam.cpython-312-darwin.so	noiseModel.py			utils
    __pycache__			gtsfm.py			symbol_shorthand.py
    

    Seems the .so file was built for 3.12, but I made sure all cmake versions where 3.10... Does this ring a possible bell, @varunagrawal ?

  3. varunagrawal commented on Sep 20, 2024

    @varunagrawal
    Collaborator

    Check the GTSAM_PYTHON_VERSION and Cmake variables for the Python version in general. This looks like it is being set to different things in different variables.

    This issue has bitten me before as well but it's a simple manual change hence I never tried to fix it.

  4. dellaert commented on Sep 21, 2024

    @dellaert< 10BC8 /div>
    MemberAuthor

    They are all 3.10

  5. dellaert commented on Sep 21, 2024

    @dellaert
    MemberAuthor

    And, I did:

    cmake -DPYTHON_EXECUTABLE=/Users/dellaert/miniforge3/envs/py310/bin/python ..
    

    And it installs in right directory. But somehow something is generating 3.12 binaries?

  6. dellaert commented on Sep 21, 2024

    @dellaert
    MemberAuthor

    It works in a conda 3.12 environment (again with custom cmake)

  7. ProfFan commented on Sep 21, 2024

    @ProfFan
    Collaborator

    @dellaert I assume you nuked the entire build folder right? Could you paste your cmake log here?

  8. dellaert commented on Sep 21, 2024

    @dellaert
    MemberAuthor

    Did you give it a try on Ubuntu with 3.10?

    PS Should CI not test all python versions we support? It should also test that cmake works out of the box in a conda or virtualenv…

  9. dellaert commented on Sep 21, 2024

    @dellaert
    MemberAuthor

    I could do a quick test with a devcontainer…

  10. ProfFan commented on Sep 22, 2024

    @ProfFan
    Collaborator

    I can test with a Docker in a sec

  11. argpravardhan commented on Jan 15, 2025

    @argpravardhan

    Hi. I think i am facing a similar issue. The compilation is going fine but during installation i see this
    image

  12. varunagrawal commented on Mar 6, 2025

    @varunagrawal
    Collaborator

    Did we manage to figure this out? @yambati03 also seemed to be bitten by this recently.

  13. DLuminary commented on Aug 24, 2026

    @DLuminary

    That's an interpreter/ABI mismatch — stubgen was invoked as a bare pybind11-stubgen from PATH at the time, picking up conda's Python rather than the one CMake configured with. That was addressed in borglab/gtsam#2029 and borglab/gtsam#2545 by switching to ${PYTHON_EXECUTABLE} -m, so #167 is probably already fixed and just not closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0