[Python] Why do I get `SystemError: <built-in method __contains__ of dict object at ...>...

Discussão em 'Python' iniciado por Stack, Maio 24, 2025.

  1. Stack

    Stack Membro Participativo

    FTR: This is my "public archival" of a Drake Slack conversation.


    gizatt Sep 17th, 2019 at 2:44 PM

    (py36_pyro) gizatt@ProblemChild:~$ python
    Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
    [GCC 7.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pydrake
    >>> import pydrake.geometry
    terminate called after throwing an instance of 'pybind11::error_already_set'
    what(): SystemError: <built-in method __contains__ of dict object at 0x7f266bd23438> returned a result with an error set
    Aborted (core dumped)


    Any ideas where to start on this one? It only happens when importing pydrake.geometry , I can import pydrake , pydrake.common , pydrake.multibody , etc first and those work OK. Python 3.6 / Ubuntu 18.04 / current master

    15 replies

    eric.cousineau 7 months ago


    Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
    ​

    I think the Anaconda part may be suspect? (see the warning at the top here: https://drake.mit.edu/python_bindings.html

    eric.cousineau 7 months ago Did it work before?

    eric.cousineau 7 months ago And can you try running it via /usr/bin/python3 , not Anaconda?

    gizatt 7 months ago I've been stably using it through conda for a while, this is new

    eric.cousineau 7 months ago Hm... Do you build it with Conda itself, or do you download the pre-built?And do you know when the last time it worked was?

    eric.cousineau 7 months ago (more specifically, the SHA1 of master?)

    gizatt 7 months ago I build it using the conda python (the same one I'm running against there), though without the conda environment sourced -- that was working OK for a while. It wasn't an upgrade of drake that broke it -- I'm suspecting some configuration tweak on my side revealed something. It broke when I was on a Drake... a week old, maybe? I upgraded and don't know what I upgraded from (edited)

    gizatt 7 months ago No sorry it's built with /usr/bin/python3.6 with no conda envs sourced. I then source a conda env and import drake and use it with the conda python, and that was great till now

    eric.cousineau 7 months ago Huh... Not sure how to help here... Are you using conda in a way that is pip compatible? Can you just do pure virtualenv , and avoid conda altogether? (we're using pyro and other stuff from pip , and it works just fine.) (edited)

    eric.cousineau 7 months ago Also, perhaps it's a difference between python3 --version on Ubuntu (3.6.8 on my machine) and Conda (3.6.9 on your machine)? (edited)

    gizatt 7 months ago I did a downgrade of the version in conda, versions are at least aligned now

    gizatt 7 months ago I moved a couple things at once so I'm not sure of the culprit yet, but I have identified that if I try to import pydrake.geometry with either of my python3.6 versions from my home directory , I get the problem, but if I do it from anywhere else, it's fine. (edited)

    gizatt 7 months ago I'll just uh... chalk this up to some import path bs and call this resolved?

    eric.cousineau 7 months ago SGTM!Though perhaps that sounds like a magical path shadowing issue, like there's a pydrake folder in your home dir? (edited)

    eric.cousineau 7 months ago (Also, some packages subscribe to the evil of installing *.pth files from setup.py or whatevs which fiddles with sys.path ... so maybe that kludges things depending on where the interpreter starts?)

    Continue reading...

Compartilhe esta Página