Skip to content

Fix running Python bindings on Windows #538

@peci1

Description

@peci1

Environment

  • OS Version: Win 10
  • Source or binary build?
    source, gz-transport14

Description

  • Expected behavior: Python bindings work
  • Actual behavior: Python bindings do not work

Steps to reproduce

  1. Install gz-transport14 from source using colcon with dependencies from conda.
  2. Run python
  3. Type from gz.transport14 import Node

Output

Traceback (most recent call last):
  File "D:\programming\gz9-ws\gz-ws\src\gz-transport\python\examples\publisher.py", line 19, in <module>
    from gz.transport14 import Node
  File "D:\programming\gz9-ws\gz-ws\install\lib\python\gz\transport14\__init__.py", line 18, in <module>
    from ._transport import Node as _Node
ImportError: DLL load failed while importing _transport: module not found

See gazebosim/gazebo_test_cases#1545 for details.

Proposed solution

Add

import os
os.add_dll_directory("C:\\Path\to\\gz-ws\\install\\bin")

to the start of python/src/init.py .

The path has to point to the directory where gz-transport14.dll is installed.

I don't know if it's better to turn the py file into a py.in and configure it via cmake, or if there is a better way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions