colcon build报错
-
zztg@zztg:~/Camera_Deep_WS$ colcon build
[0.193s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'ros' in 'src/OrbbecSDK_ROS2/orbbec_camera_msgs': 'utf-8' codec can't decode byte 0x80 in position 132: invalid start byte
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_core/package_identification/init.py", line 144, in _identify
retval = extension.identify(_reused_descriptor_instance)
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 55, in identify
pkg, build_type = get_package_with_build_type(str(desc.path))
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 166, in get_package_with_build_type
pkg = _get_package(path)
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 183, in _get_package
pkg = parse_package(path)
File "/usr/lib/python3/dist-packages/catkin_pkg/package.py", line 583, in parse_package
xml, filename = _get_package_xml(path)
File "/usr/lib/python3/dist-packages/catkin_pkg/package.py", line 525, in _get_package_xml
return f.read(), filename
File "/usr/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 132: invalid start byte[0.194s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'ros' in 'src/OrbbecSDK_ROS2/orbbec_description': 'utf-8' codec can't decode byte 0x80 in position 132: invalid start byte
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_core/package_identification/init.py", line 144, in _identify
retval = extension.identify(_reused_descriptor_instance)
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 55, in identify
pkg, build_type = get_package_with_build_type(str(desc.path))
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 166, in get_package_with_build_type
pkg = _get_package(path)
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 183, in _get_package
pkg = parse_package(path)
File "/usr/lib/python3/dist-packages/catkin_pkg/package.py", line 583, in parse_package
xml, filename = _get_package_xml(path)
File "/usr/lib/python3/dist-packages/catkin_pkg/package.py", line 525, in _get_package_xml
return f.read(), filename
File "/usr/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 132: invalid start byte[0.196s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'ros' in 'src/yahboomcar_astra': 'utf-8' codec can't decode byte 0x80 in position 132: invalid start byte
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_core/package_identification/init.py", line 144, in _identify
retval = extension.identify(_reused_descriptor_instance)
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 55, in identify
pkg, build_type = get_package_with_build_type(str(desc.path))
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 166, in get_package_with_build_type
pkg = _get_package(path)
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 183, in _get_package
pkg = parse_package(path)
File "/usr/lib/python3/dist-packages/catkin_pkg/package.py", line 583, in parse_package
xml, filename = _get_package_xml(path)
File "/usr/lib/python3/dist-packages/catkin_pkg/package.py", line 525, in _get_package_xml
return f.read(), filename
File "/usr/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 132: invalid start byteTraceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.8/distutils/core.py", line 215, in run_setup
exec(f.read(), g)
ValueError: source code string cannot contain null bytes
[0.372s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'python_setup_py' in 'src/yahboomcar_visual': Command '['/usr/bin/python3', '-c', 'import sys;from contextlib import suppress;exec("with suppress(ImportError): from setuptools.extern.packaging.specifiers import SpecifierSet");exec("with suppress(ImportError): from packaging.specifiers import SpecifierSet");from distutils.core import run_setup;dist = run_setup( 'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = { key: value for key, value in dist.dict.items() if ( not key.startswith('_') and not callable(value) and key not in skip_keys and key not in dist.display_option_names )};data['metadata'] = { k: v for k, v in dist.metadata.dict.items() if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))']' returned non-zero exit status 1.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_core/package_identification/init.py", line 144, in _identify
retval = extension.identify(_reused_descriptor_instance)
File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 48, in identify
config = get_setup_information(setup_py)
File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 249, in get_setup_information
_setup_information_cache[hashable_env] = _get_setup_information(
File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 296, in get_setup_information
result = subprocess.run(
File "/usr/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', 'import sys;from contextlib import suppress;exec("with suppress(ImportError): from setuptools.extern.packaging.specifiers import SpecifierSet");exec("with suppress(ImportError): from packaging.specifiers import SpecifierSet");from distutils.core import run_setup;dist = run_setup( 'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = { key: value for key, value in dist.dict.items() if ( not key.startswith('') and not callable(value) and key not in skip_keys and key not in dist.display_option_names )};data['metadata'] = { k: v for k, v in dist.metadata.dict.items() if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))']' returned non-zero exit status 1.Starting >>> orbbec_camera_msgs
Starting >>> orbbec_description
Starting >>> ros2_orbslam
Starting >>> yahboomcar_KCFTracker
Starting >>> yahboomcar_mediapipe
Starting >>> yahboomcar_msgs
Starting >>> yahboomcar_slam
Failed <<< orbbec_camera_msgs [0.19s, exited with code 1]
Failed <<< orbbec_description [0.18s, exited with code 1]
Failed <<< yahboomcar_KCFTracker [0.18s, exited with code 1]
Aborted <<< yahboomcar_mediapipe [0.17s]
Aborted <<< ros2_orbslam [1.07s]
Aborted <<< yahboomcar_msgs [1.27s]
Aborted <<< yahboomcar_slam [1.42s]Summary: 0 packages finished [1.79s]
3 packages failed: orbbec_camera_msgs orbbec_description yahboomcar_KCFTracker
4 packages aborted: ros2_orbslam yahboomcar_mediapipe yahboomcar_msgs yahboomcar_slam
1 package had stderr output: ros2_orbslam
1 package not processed -
从您提供的错误信息来看,主要问题在于
colcon build
过程中尝试读取和解析某些 ROS 包的package.xml
文件时遇到了编码问题。错误提示'utf-8' codec can't decode byte 0x80 in position 132: invalid start byte
表明在解析这些文件时,Python 解释器无法用 UTF-8 编码来解码某些字节。这通常意味着package.xml
文件可能被错误地保存为其他编码格式,或者文件已损坏。此外,还有一个关于
setup.py
的错误,这可能是因为文件包含了无法用 UTF-8 解码的 null 字节。以下是一些可能的解决步骤:
-
检查
package.xml
文件的编码:- 使用文本编辑器(如 VSCode, Sublime Text, 或 Notepad++)打开出错的
package.xml
文件。 - 查看并确认文件的编码是否为 UTF-8。如果不是,尝试将文件保存为 UTF-8 编码。
- 检查文件是否有不可见的特殊字符或损坏的部分。
- 使用文本编辑器(如 VSCode, Sublime Text, 或 Notepad++)打开出错的
-
清理和修复
setup.py
文件:- 打开
src/yahboomcar_visual
目录下的setup.py
文件。 - 检查文件中是否有 null 字节(通常是不可见的,但可以通过一些高级文本编辑器检测)。
- 确保文件是干净且正确编码为 UTF-8。
- 打开
-
重新生成或恢复
package.xml
和setup.py
:- 如果可能,尝试从源代码管理(如 Git)或其他备份中恢复这些文件。
- 对于 ROS 包,如果
package.xml
文件丢失或损坏,可以重新使用catkin_create_pkg
或ros2 pkg create
命令来生成新的包结构。
-
使用命令行工具检查文件:
- 在 Linux 上,你可以使用
file
命令来检查文件的编码类型,例如:file -bi package.xml
。 - 使用
iconv
或其他工具尝试转换文件编码。
- 在 Linux 上,你可以使用
-
清理和重建工作空间:
- 在工作空间中运行
colcon clean
来清理之前的构建结果。 - 再次尝试
colcon build
。
- 在工作空间中运行
如果上述步骤仍然无法解决问题,可能需要更深入地检查 ROS 包的源代码或寻求从包的维护者那里获取帮助。
以上为生成回答,仅供参考~
-