Robotics StackExchange | Archived questions

How to install tf2_geometry_msgs dependency PyKDL?

When importing tf2_geometry_msgs in a Python script running a node in ROS Noetic, I keep getting the following error indicating that I need to install PyKDL.

 Traceback (most recent call last):
  File "/home/user/catkin_ws/devel/lib/my_package/my_node.py", line 15, in <module>
    exec(compile(fh.read(), python_script, 'exec'), context)
  File "/home/user/catkin_ws/src/my_package/src/my_node.py", line 6, in <module>
    import tf2_geometry_msgs
  File "/opt/ros/noetic/lib/python3/dist-packages/tf2_geometry_msgs/__init__.py", line 1, in <module>
    from .tf2_geometry_msgs import *
  File "/opt/ros/noetic/lib/python3/dist-packages/tf2_geometry_msgs/tf2_geometry_msgs.py", line 31, in <module>
    import PyKDL
ModuleNotFoundError: No module named 'PyKDL'

When I try to install PyKDL using pip3 install PyKDL, I get the following error:

Collecting PyKDL
  Downloading PyKDL-1.4.0.tar.gz (1.5 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rtk9wxen/PyKDL/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rtk9wxen/PyKDL/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-rtk9wxen/PyKDL/pip-egg-info
         cwd: /tmp/pip-install-rtk9wxen/PyKDL/
    Complete output (7 lines):
    running egg_info
    creating /tmp/pip-install-rtk9wxen/PyKDL/pip-egg-info/PyKDL.egg-info
    writing /tmp/pip-install-rtk9wxen/PyKDL/pip-egg-info/PyKDL.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-install-rtk9wxen/PyKDL/pip-egg-info/PyKDL.egg-info/dependency_links.txt
    writing top-level names to /tmp/pip-install-rtk9wxen/PyKDL/pip-egg-info/PyKDL.egg-info/top_level.txt
    writing manifest file '/tmp/pip-install-rtk9wxen/PyKDL/pip-egg-info/PyKDL.egg-info/SOURCES.txt'
    error: package directory 'PyKDL' does not exist
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

This is frustrating because everything was working great yesterday and I'm unsure what has changed in my ROS setup. My issue seems to be referenced in the Noetic Migration Guide here but it is not clear to me exactly what I need to do to install the required dependency.

Any ideas?

Asked by Py on 2021-06-12 06:11:51 UTC

Comments

face same issue, any ideas?

Asked by Dio on 2022-01-27 01:01:02 UTC

Answers

build with the instruction here: https://github.com/orocos/orocos_kinematics_dynamics/blob/release-1.5/python_orocos_kdl/INSTALL.md

And, you'll get a PyKDL.so file here: ./build/devel/lib/python3/dist-packages/PyKDL.so

orocos_kinematics_dynamics/python_orocos_kdl$ find . | egrep "\.so"
./build/devel/lib/python3/dist-packages/PyKDL.so

Then, copy the file to your env's dynamic library path. For example, I'm using conda and python 3.8, I'll do this:

cp ./build/devel/lib/python3/dist-packages/PyKDL.so ~/miniconda3/envs/py3/lib/python3.8/lib-dynload

Then, you can use command below to check whether it works:

python -c "import PyKDL"

Asked by lamuguo on 2022-01-28 12:28:09 UTC

Comments

I am getting "error: static assertion failed: The number of argument annotations does not match the number of function arguments" when doing make for python_orocos_kdl

Asked by zkytony on 2022-02-08 19:37:17 UTC

Here is a work around. I found that I could install PyKDL by sudo apt install python3-pykdl This installs a library to /usr/lib/python3/dist-packages/PyKDL.cpython-38-x86_64-linux-gnu.so.

Then, I made sure that my PYTHONPATH contains /usr/lib/python3/dist-packages/. Now, import PyKDL finally succeeds.

Asked by zkytony on 2022-02-08 20:22:35 UTC

Comments

Hello, how to solve this problem after adding 'PyKDL', I tried to update sip, but there is still a version conflict problem.

NODES / shadow_tc_learn_to_pick_ball_qlearn (my_shadow_tc_openai_example/start_qlearning_v2.py)

ROS_MASTER_URI=http://localhost:11311

process[shadow_tc_learn_to_pick_ball_qlearn-1]: started with pid [208521] Failed to import pyassimp, see https://github.com/ros-planning/moveit/issues/86 for more info Traceback (most recent call last): File "/home/ljh0929/ros_robot/tcrobot_ws/src/openai_examples_projects/my_shadow_tc_openai_example/scripts/start_qlearning_v2.py", line 25, in env = StartOpenAI_ROS_Environment( File "/home/ljh0929/ros_robot/tcrobot_ws/src/openai_ros/openai_ros/src/openai_ros/openai_ros_common.py", line 28, in StartOpenAI_ROS_Environment result = RegisterOpenAI_Ros_Env(task_env=task_and_robot_environment_name, File "/home/ljh0929/ros_robot/tcrobot_ws/src/openai_ros/openai_ros/src/openai_ros/task_envs/task_envs_list.py", line 128, in RegisterOpenAI_Ros_Env from openai_ros.task_envs.shadow_tc import learn_to_pick_ball File "/home/ljh0929/ros_robot/tcrobot_ws/src/openai_ros/openai_ros/src/openai_ros/task_envs/shadow_tc/learn_to_pick_ball.py", line 4, in from openai_ros.robot_envs import shadow_tc_env File "/home/ljh0929/ros_robot/tcrobot_ws/src/openai_ros/openai_ros/src/openai_ros/robot_envs/shadow_tc_env.py", line 8, in from smart_grasping_sandbox.smart_grasper import SmartGrasper File "/home/ljh0929/ros_robot/simulation_ws/src/shadow_robot_smart_grasping_sandbox/smart_grasping_sandbox/smart_grasping_sandbox/src/smart_grasping_sandbox/smart_grasper.py", line 19, in from tf_conversions import posemath, toMsg File "/opt/ros/noetic/lib/python3/dist-packages/tf_conversions/init.py", line 30, in from .posemath import * File "/opt/ros/noetic/lib/python3/dist-packages/tf_conversions/posemath.py", line 34, in from PyKDL import * RuntimeError: the sip module implements API v12.0 to v12.5 but the PyKDL module requires API v12.7 [shadow_tc_learn_to_pick_ball_qlearn-1] process has died [pid 208521, exit code 1, cmd /home/ljh0929/ros_robot/tcrobot_ws/src/openai_examples_projects/my_shadow_tc_openai_example/scripts/start_qlearning_v2.py __name:=shadow_tc_learn_to_pick_ball_qlearn __log:=/home/ljh0929/.ros/log/e703a6a2-ba23-11ec-9644-27d424b3334b/shadow_tc_learn_to_pick_ball_qlearn-1.log]. log file: /home/ljh0929/.ros/log/e703a6a2-ba23-11ec-9644-27d424b3334b/shadow_tc_learn_to_pick_ball_qlearn-1*.log all processes on machine have died, roslaunch will exit shutting down processing monitor...

Asked by liu871795683 on 2022-04-12 04:14:21 UTC

Comments