How to solve the error occurred when I try to use function in tf_conversions in ROS1-melodic in a python3 environment

huangapple go评论86阅读模式
英文:

How to solve the error occurred when I try to use function in tf_conversions in ROS1-melodic in a python3 environment

问题

我正在学习ROS Melodic,但我的Python环境是通过Anaconda创建的,版本是3.9。因此,当我尝试使用tf_conversions中的函数时,出现了一个错误,错误消息为ImportError: dynamic module does not define module export function (PyInit_PyKDL)

我在互联网上搜索了一下,他们都说我应该重新构建pybind11和PyKDL库。所以我克隆了orocos_kinematics_dynamics仓库,并成功构建了orocos_kinematics_dynamics/orocos_kdl C++库。但是,每当我尝试使用orocos_kinematics_dynamics/python_orocos_kdl构建Python库时,在进行make步骤时,就会出现以下错误:

In file included from /usr/local/include/pybind11/attr.h:13:0,
                 from /usr/local/include/pybind11/detail/class.h:12,
                 from /usr/local/include/pybind11/pybind11.h:13,
                 from /home/dongxuan/catkin_ws_test/src/python_orocos_kdl/PyKDL/PyKDL.h:26,
                 from /home/dongxuan/catkin_ws_test/src/python_orocos_kdl/PyKDL/PyKDL.cpp:27:
/usr/local/include/pybind11/detail/common.h:269:6: error: #error "PYTHON < 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5."
 #    error "PYTHON < 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5."

以及后续的许多其他错误。但如果我键入python --version,它将显示3.9.12。所以我不知道哪里的设置不合适。

英文:

I am learning ROS-melodic, but my python environment is created by anaconda and is 3.9. So when I try to use functions in tf_conversions, an error saying ImportError: dynamic module does not define module export function (PyInit_PyKDL) occurred

I searched the Internet and they all say that I should rebuild the pybind11 and PyKDL library. So I cloned the orocos_kinematics_dynamics repository down and built successfully with the orocos_kinematics_dynamics/orocos_kdl c++ lib, but whenever I tried to build python lib with the orocos_kinematics_dynamics/python_orocos_kdl, when doing make step, the error would occur:

In file included from /usr/local/include/pybind11/attr.h:13:0,
                 from /usr/local/include/pybind11/detail/class.h:12,
                 from /usr/local/include/pybind11/pybind11.h:13,
                 from /home/dongxuan/catkin_ws_test/src/python_orocos_kdl/PyKDL/PyKDL.h:26,
                 from /home/dongxuan/catkin_ws_test/src/python_orocos_kdl/PyKDL/PyKDL.cpp:27:
/usr/local/include/pybind11/detail/common.h:269:6: error: #error &quot;PYTHON &lt; 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5.&quot;
 #    error &quot;PYTHON &lt; 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5.&quot;

And lots of more errors in subsequence.
But if I type python --version, it will show 3.9.12. so I don't know where the setting is unsuitable.

答案1

得分: 0

ROS Melodic 原生支持 Python2.7,而不支持 >=3。有一些解决方法尝试使 Python3 与 Melodic 兼容,但其中没有一个应被视为稳定。

对于 ROS1,Noetic 是唯一原生支持 Python3 的版本。如果需要使用 Python3 模块,您应该只使用 Noetic。

英文:

ROS Melodic is built natively for Python2.7, not >=3. There are workarounds to try and get Python3 working with Melodic, but none of them should be considered stable.

For ROS1 Noetic is the only distro that natively supports Python3. If you need to use modules with Python3 you should only be using Noetic.

huangapple
  • 本文由 发表于 2023年6月15日 21:58:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76483246.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定