ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

xacro: substitution args not supported: No module named 'rospkg'

asked 2019-08-23 05:46:45 -0600

karburettor gravatar image

updated 2022-05-28 16:44:58 -0600

lucasw gravatar image

I am an absolute beginner to Ubuntu and ROS and to such q/a forums, so please be forgiving. I am using Ubuntu 18.04.3 and running ROS Melodic. I am following an old Udacity course archive. It is about a package called simple_arm which I cloned from (https://github.com/udacity/simple_arm... )

I have created my catkin workspace, initialized it, cloned from github, ran catkin_make, sourced bash.setup as according to instructions. However I get an error when run the launch command:

roslaunch simple_arm robot_spawn.launch

The error i receive is:

... logging to /home/karthik/.ros/log/5ae6a64a-c58b-11e9-8b56-34e6ad8bdd6e/roslaunch-UnitedForever-17751.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

xacro: in-order processing became default in ROS Melodic. You can drop the option. substitution args not supported:  No module named 'rospkg'
when processing file: /home/karthik/catkin_ws/src/simple_arm/urdf/simple_arm.urdf.xacro
RLException: while processing /home/karthik/catkin_ws/src/simple_arm/launch/robot_description.xml: Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/melodic/lib/xacro/xacro --inorder '/home/karthik/catkin_ws/src/simple_arm/urdf/simple_arm.urdf.xacro'] returned with code [2].  Param xml is <param command="$(find xacro)/xacro --inorder '$(find simple_arm)/urdf/simple_arm.urdf.xacro'" name="robot_description"/> The traceback for the exception was written to the log file 
edit retag flag offensive close merge delete

Comments

Did you change anything from the code? I just cloned the repo and it works for me...

ffusco gravatar image ffusco  ( 2019-08-23 09:35:59 -0600 )edit

5 Answers

Sort by ยป oldest newest most voted
5

answered 2019-08-25 06:12:02 -0600

karburettor gravatar image

I had installed Anaconda. It had changed some python path. Uninstalling it and running above code solved the error. Thanks.

edit flag offensive delete link more

Comments

I faced the same error. Fixed it by uninstalling anaconda3 Thanks!

Rahul K R gravatar image Rahul K R  ( 2020-02-05 07:13:48 -0600 )edit
1

I faced the same error however instead of uninstalling Anaconda I install rospkg with Anaconda by running conda install -c conda-forge rospkg (got this from https://anaconda.org/conda-forge/rospkg). This way you don't have to uninstall Anaconda

sia gravatar image sia  ( 2020-04-03 10:30:11 -0600 )edit

I am using virtualenvironment instead of anaconda. Do you have any suggestions on how to solve this error?

fabbro gravatar image fabbro  ( 2020-06-02 04:55:12 -0600 )edit

you can deactivate your conda/venv environment. Now its looks for system-level python instead of your environment.

PavanMV gravatar image PavanMV  ( 2021-07-03 04:45:48 -0600 )edit
1

answered 2022-12-16 20:32:14 -0600

jstm gravatar image

I was getting the same error. The issue was that I was in a virtual environment. If your in one that's likely the issue - just run deactivate / conda deactivate

edit flag offensive delete link more
0

answered 2020-12-29 16:34:35 -0600

everything gravatar image

updated 2020-12-30 09:01:21 -0600

I solved that error by the following steps, I do not know which one is essential and which one can be left out.

  • In the base environment:
    • Uninstall any Python packages (scipy, pyyaml, rospkg, ...) that I have accidentally installed outside my virtual environment (Python3.6, Python3.7, Python2.7) and that are only meant for the Python2.7 virtual env that I use for melodic.
    • Re-install catkin workspace (remove build, devel, and CMake_Lists.txt in /src from your project folder; source ros; compile with catkin_make ... again; source compilation). Not sure if that has changed anything, in this rospkg case, though.
    • sudo apt-get install virtualenv
    • sudo apt-get install python-pip
    • Make sure that python command uses python2.7.
    • Create your virtual environment using python -m virtualenv -p python2.7 YOURVENV.
    • Activate YOURVENV with source YOURVENV/bin/activate.
  • In YOURVENV:
    • sudo apt-get install python-scipy (apt-get installs globally, but elsewise, I got errors when launching)
    • sudo apt-get install python-rospkg (same as with scipy, but better keep to an install inside your venv using pip)
    • Install other needed packages using python -m pip install ... (or sudo apt-get install ..., but I did not use it). In case that there are issues with the old python2.7, take the latest version of a package that is avaialbe for pip2 / python -m pip. I had to install opencv-python==4.2.0.32 because the later opencv was not supported, see Python 2.7 installing opencv via pip (virtual environment).
    • Run roslaunch YOURLAUNCHFILE.launch.

In short:

  • Uninstall from the base any possibly concurring packages that are only needed in your venv (especially those which have not been installed with sudo apt) and that are not part of the default base.

  • Re-installing the catkin workspace is not that much work in the end, that is why I would generally recommend it when in doubts about the cause of an error.

  • Use pip install over sudo apt-getif possible (apt install causes no version conflicts and sometimes could help me going on, on the other hand apt-get does not care about the venv but installs globally, which is not the best approach in bigger projects. It is a bit ambiguous, see for example also comments at https://stackoverflow.com/questions/4...: sometimes apt-get can solve it for whatever reason...).

  • If you use pip install, make clear which python you use with python -m pip install (that is somehow best practice, check python -V = 2.7 if that is needed.

edit flag offensive delete link more
0

answered 2019-08-23 11:03:53 -0600

Just wanting to make sure, you do have rospkg installed, right?

sudo apt-get install python-rospkg

edit flag offensive delete link more

Comments

Yes. Sorry for not mentioning.

karburettor gravatar image karburettor  ( 2019-08-25 06:08:35 -0600 )edit
0

answered 2020-10-03 10:06:31 -0600

fjp gravatar image

In my case the problem was the PlatformIO plugin of vscode. When trying to launch a launch file from within vscode terminal the mentioned error appeared. Launching in a standard Ubuntu terminal works without errors. So for me the preliminary solution was uninstalling PlatformIO vscode plugin and restarting vscode.

I think PlatformIO creates its own Python environment.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-08-23 05:43:26 -0600

Seen: 9,867 times

Last updated: Dec 16 '22