AttributeError: 'module' object has no attribute 'main'
Hello all!
I want to run turtlebot simulation. It has been complied correctly. But I run the main.launch
file it gives me the following error.
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/xacro/xacro", line 33, in <module>
xacro.main()
AttributeError: 'module' object has no attribute 'main'
while processing /home/ibrahim/catkin_ws/src/turtlebot_simulator/turtlebot_gazebo/launch/includes/kobuki.launch.xml:
Invalid <param> tag: Cannot load command parameter [turtlebot_description]: command [/opt/ros/kinetic/lib/xacro/xacro --inorder '/home/ibrahim/catkin_ws/src/turtlebot/turtlebot_description/robots/kobuki_hexagons_asus_xtion_pro.urdf.xacro'] returned with code [1].
Param xml is <param command="$(arg urdf_file)" name="turtlebot_description"/>
The traceback for the exception was written to the log file
In the initial lines it says no attribute main
but I visit the address of this xacro.py file and I opened it with my editor like Visual Studio Code or can be opened with some other editors.
following are the contents of xacro.py file.
some comments are there but with just two lines of code.
import xacro
xacro.main()
So I removed main() and type again to check if it recognizes this function or not. so besides main() there are other attributes like math, macro, message
etc appear in the sub menu.
So main() function/attribute is there. I visited some similar posts but it didn't help me. If someone has faced this problem and solved it. Please help me to find its solution. Thanks.
when I type /opt/ros/kinetic/lib/xacro/xacro --inorder '/home/ibrahim/catkin_ws/src/turtlebot/turtlebot_description/robots/kobuki_hexagons_asus_xtion_pro.urdf.xacro'
. It gives the following info.
<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from /home/ibrahim/catkin_ws/src/turtlebot/turtlebot_description/robots/kobuki_hexagons_asus_xtion_pro.urdf.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<!--
- Base : kobuki
- Stacks : hexagons
- 3d Sensor : kinect
-->
<robot name="turtlebot" xmlns:xacro="http://ros.org/wiki/xacro">
<kobuki/>
<stack_hexagons parent="base_link"/>
<sensor_asus_xtion_pro parent="base_link"/>
</robot>
Command for running launch file is
roslaunch gym_construct main.launch
I want to run simulation environment so I can deploy and train turtlebot robot in it. First I need to run this environment and then run the package for turtlebot2. I am using openai_ROS.
Do you have an alternative Python interpreter installed (Anaconda)? Or Python 3? What is the output of
which python
andpython --version
?Also:
source /opt/ros/kinetic/setup.bash && python -c 'import xacro'
.@gvdhoorn by typing
which python
it returns /usr/bin/python, and by typingpython --version
it gives me python 2.7.12 as I installed python 2.7 and I sourced itsource /opt/ros/kinetic/setup.bash && python -c 'import xacro'
but the error exits.I'm not sure what you mean by that.
Does executing that line result in an error saying
ImportError: No module named xacro
?How did you install ROS? Using
apt-get
(orapt
) or did you build from sources?@gvdhoorn bro I installed ROS long time ago I don't remember whether I installed it using
apt-get
orapt
. by typingsource /opt/ros/kinetic/setup.bash && python -c 'import xacro'
I get nothing display. But this error appears for another package as well. If you can help me, I shall be thankful.I am not your bro, but if
source /opt/ros/kinetic/setup.bash && python -c 'import xacro'
doesn't give you the same error, then at leastxacro
appears to be installed.What is the output of
dpkg -l | grep xacro
?the output is
Ok. And what is the output of:
Please edit your original question and append the new output.
Do not use comments for it.