编译功能包报错
-
报错日志:
root@ubuntu:~/fx_cz_ws# source /opt/ros/humble/setup.bash root@ubuntu:~/fx_cz_ws# colcon build Starting >>> micro_ros_msgs Starting >>> robot_interfaces --- stderr: micro_ros_msgs Traceback (most recent call last): File "/root/fx_cz_ws/build/micro_ros_msgs/ament_cmake_python/micro_ros_msgs/setup.py", line 4, in <module> setup( File "/usr/local/lib/python3.10/dist-packages/setuptools/__init__.py", line 117, in setup return distutils.core.setup(**attrs) File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/core.py", line 186, in setup return run_commands(dist) File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/core.py", line 202, in run_commands dist.run_commands() File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 983, in run_commands self.run_command(cmd) File "/usr/local/lib/python3.10/dist-packages/setuptools/dist.py", line 993, in run_command super().run_command(command) File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 1002, in run_command cmd_obj.run() File "/usr/local/lib/python3.10/dist-packages/setuptools/command/egg_info.py", line 312, in run self.find_sources() File "/usr/local/lib/python3.10/dist-packages/setuptools/command/egg_info.py", line 320, in find_sources mm.run() File "/usr/local/lib/python3.10/dist-packages/setuptools/command/egg_info.py", line 548, in run self.prune_file_list() File "/usr/local/lib/python3.10/dist-packages/setuptools/command/sdist.py", line 162, in prune_file_list super().prune_file_list() File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/command/sdist.py", line 380, in prune_file_list base_dir = self.distribution.get_fullname() File "/usr/local/lib/python3.10/dist-packages/setuptools/_core_metadata.py", line 267, in get_fullname return _distribution_fullname(self.get_name(), self.get_version()) File "/usr/local/lib/python3.10/dist-packages/setuptools/_core_metadata.py", line 285, in _distribution_fullname canonicalize_version(version, strip_trailing_zero=False), TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero' gmake[2]: *** [CMakeFiles/ament_cmake_python_build_micro_ros_msgs_egg.dir/build.make:70:CMakeFiles/ament_cmake_python_build_micro_ros_msgs_egg] 错误 1 gmake[1]: *** [CMakeFiles/Makefile2:447:CMakeFiles/ament_cmake_python_build_micro_ros_msgs_egg.dir/all] 错误 2 gmake[1]: *** 正在等待未完成的任务.... gmake: *** [Makefile:146:all] 错误 2 --- Failed <<< micro_ros_msgs [20.0s, exited with code 2] Aborted <<< robot_interfaces [20.8s] Summary: 0 packages finished [22.0s] 1 package failed: micro_ros_msgs 1 package aborted: robot_interfaces 2 packages had stderr output: micro_ros_msgs robot_interfaces 1 package not processed
-
从错误日志来看,问题发生在编译
micro_ros_msgs
包时,具体是在 Python 的setup.py
脚本执行过程中遇到了一个TypeError
。错误的根源在于canonicalize_version()
函数调用时传入了一个不被期望的关键字参数strip_trailing_zero
。这个错误通常是由于
setuptools
库的版本与其他依赖库不兼容所导致的。可能的解决方案包括:-
检查并更新
setuptools
版本:
setuptools
的某些版本可能与其他依赖库不兼容。尝试更新setuptools
到最新版本,看是否可以解决问题。可以使用以下命令来更新:pip install --upgrade setuptools
注意,由于你使用的是 ROS Humble,可能需要确保在 ROS 的 Python 环境中更新
setuptools
。你可以使用rosdep
或 ROS 自带的包管理工具来确保环境的一致性。 -
检查其他依赖库的版本:
如果更新setuptools
后问题依旧存在,可能需要检查其他依赖库的版本是否兼容。特别是与setuptools
紧密相关的库,如wheel
或packaging
等。 -
使用虚拟环境:
为了避免系统级别的包冲突,可以考虑使用 Python 虚拟环境来隔离 ROS 和其他 Python 项目。使用venv
或conda
创建一个新的环境,并在其中安装 ROS 和相关依赖。 -
回退到旧版本的
setuptools
:
如果更新到最新版本后问题更糟,或者新版本与 ROS 不兼容,可以尝试回退到之前的版本。你可以通过查找错误报告或社区讨论来确定哪个版本是稳定的。 -
查看 ROS 社区和 GitHub 问题跟踪:
有时候,这类问题可能已经被其他用户遇到并报告。查看 ROS 的官方 GitHub 仓库或相关社区论坛,看看是否有其他用户报告了相同的问题,并找到了解决方案。 -
清理构建环境:
有时候,旧的构建文件可能会导致问题。尝试清理你的构建环境(如删除build
和install
目录),然后重新运行colcon build
。
希望这些建议能帮助你解决问题!如果问题依旧存在,可能需要更详细的错误信息或日志来进一步诊断。
以上为生成回答,仅供参考~
-
-
@43996173 系统平台?删掉已经构建的install build log 再试试
-
@小鱼 可以在conda环境下吗?
-
@43996173 当然不行
-
@小鱼 问题已解决:
pip install setuptools==64 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting setuptools==64 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3e/83/e206edff58159a927c76bbfeef1bf8b39cb12bbb32ae3c6227deb16d0121/setuptools-64.0.0-py3-none-any.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 3.7 MB/s eta 0:00:00 WARNING: Error parsing dependencies of send2trash: Expected matching RIGHT_PARENTHESIS for LEFT_PARENTHESIS, after version specifier sys-platform (=="darwin") ; extra == 'objc' ~^ Installing collected packages: setuptools Attempting uninstall: setuptools Found existing installation: setuptools 75.7.0 Uninstalling setuptools-75.7.0: Successfully uninstalled setuptools-75.7.0 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. sip 6.9.1 requires setuptools>=69.5, but you have setuptools 64.0.0 which is incompatible. Successfully installed setuptools-64.0.0 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning. root@ubuntu:~# sudo pip install sqlmap -U Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting sqlmap Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4a/63/07583bdfb9079d4080287727f43a691f54166200e13e9cd2ea0092f58142/sqlmap-1.9.tar.gz (7.2 MB) Preparing metadata (setup.py) ... done Building wheels for collected packages: sqlmap Building wheel for sqlmap (setup.py) ... done Created wheel for sqlmap: filename=sqlmap-1.9-py3-none-any.whl size=7553947 sha256=5390d456e7fd49453a409c541bbc685a044e4e7af15e4ddb62bde8d5c0c7499a Stored in directory: /root/.cache/pip/wheels/89/6c/55/46f213852194b692cba553eddad03682b30067f9f7a0fda9d7 Successfully built sqlmap WARNING: Error parsing dependencies of send2trash: Expected matching RIGHT_PARENTHESIS for LEFT_PARENTHESIS, after version specifier sys-platform (=="darwin") ; extra == 'objc' ~^ Installing collected packages: sqlmap Successfully installed sqlmap-1.9 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
-
@小鱼 RS485例程还是无法找到功能包
-
@43996173 不行直接python 加文件名字先运行着