紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
-
@小鱼 基本是复制下来的
msg:string content sensor_msgs/Image image
cmake.txt
cmake_minimum_required(VERSION 3.8) project(demo_interface) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() find_package(ament_cmake REQUIRED) find_package(sensor_msgs REQUIRED) find_package(rosidl_default_generators REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "msg/Novel.msg" DEPENDENCIES sensor_msgs ) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) set(ament_cmake_copyright_FOUND TRUE) set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() ament_package()
package.xml
<?xml version="1.0"?> <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> <package format="3"> <name>demo_interface</name> <version>0.0.0</version> <description>TODO: Package description</description> <maintainer email="li-xiaoqiang@outlook.com">li</maintainer> <license>TODO: License declaration</license> <buildtool_depend>ament_cmake</buildtool_depend> <test_depend>ament_lint_auto</test_depend> <test_depend>ament_lint_common</test_depend> <depend>sensor_msgs</depend> <build_depend>rosidl_default_generators</build_depend> <exec_depend>rosidl_default_runtime</exec_depend> <member_of_group>rosidl_interface_packages</member_of_group> <export> <build_type>ament_cmake</build_type> </export> </package>
安装过anaconda,但编译的时候是关闭的,不在conda环境里。
-
@LI 还真没看出来错误,但是和conda估计还是有些关系,我们再检查一下这个文件,你贴一下里面的内容
/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/__init__.py
-
@LI 刚去检索了下,看到一个相同的问题,是出在conda上,你试试打开一个新的终端,运行下面的指令,如果可以成功,那就是conda确实没退出或者对PYTHONPATH产生了什么影响
$ conda deactivate $ python3 -c 'from rosidl_generator_py import generate_py'
-
@小鱼 /opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/init.py是这样的
# Copyright 2014-2015 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import logging import traceback from .import_type_support_impl import import_type_support __all__ = ['import_type_support'] try: from .generate_py_impl import generate_py assert generate_py __all__.append('generate_py') except ImportError: logger = logging.getLogger('rosidl_generator_py') logger.debug( 'Failed to import modules for generating Python structures:\n' + traceback.format_exc())
尝试了那两行命令,仍旧是同样的报错
-
@LI 那就尝试用pip卸载重新安装写这个缺少的模块,不过这个模块代码应该就在你电脑上
-
@小鱼 最后靠着重装ros2,没改文件内容,解决了问题
-
@LI 解决环境问题最好的办法就是重装了
-
@小鱼 鱼哥,我也遇到这个问题了。这个问题到底怎么解决呀,重装了ros也没用
-
@晤易 你是哪个版本的ros2
-
@小鱼 humble 版本的
-
找了半天才找到这个解决办法,系统是22.04,安装ros humble,也是报相同的错误,亲测是Conda和本机环境冲突,需要用鱼哥说的在安装中先
conda deactivate
-
@沉淀 我是 conda deactivate了还是报错,然后把之前的编译文件和日志都删除了,再重新编译就不报错了
-
-
@晤易 我的情况按照你说的解决了,这个坑困扰我了一下午了。