ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
5

How to install tf2_geometry_msgs dependency PyKDL?

asked 2021-06-12 06:11:51 -0500

Py gravatar image

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?

edit retag flag offensive close merge delete

Comments

face same issue, any ideas?

Dio gravatar image Dio  ( 2022-01-27 00:01:02 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2022-04-12 04:14:21 -0500

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/movei... 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 <module> 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 <module> 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 <module> 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 <module> from tf_conversions import posemath, toMsg File "/opt/ros/noetic/lib/python3/dist-packages/tf_conversions/__init__.py", line 30, in <module> from .posemath import * File "/opt/ros/noetic/lib/python3/dist-packages/tf_conversions/posemath.py", line 34, in <module> 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...</module></module></module></module></module></module>

edit flag offensive delete link more
0

answered 2022-02-08 19:22:35 -0500

zkytony gravatar image

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.

edit flag offensive delete link more
1

answered 2022-01-28 11:28:09 -0500

lamuguo gravatar image

build with the instruction here: https://github.com/orocos/orocos_kine...

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"
edit flag offensive delete link more

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

zkytony gravatar image zkytony  ( 2022-02-08 18:37:17 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2021-06-12 06:11:51 -0500

Seen: 4,231 times

Last updated: Feb 08 '22