gazebosim / gz-transport

Transport library for component communication based on publication/subscription and service calls.
https://gazebosim.org
Apache License 2.0
29 stars 43 forks source link

Fix running Python bindings on Windows #538

Open peci1 opened 2 months ago

peci1 commented 2 months ago

Environment

Description

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 https://github.com/gazebosim/gazebo_test_cases/issues/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.

traversaro commented 1 month ago

Related issue: https://github.com/gazebosim/gz-math/issues/507 .