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

Import error: No module named 'glob'

asked 2017-10-30 10:34:22 -0500

updated 2017-10-30 10:35:05 -0500

Dear all, I got an import error from executing roslaunch pr2_gazebo pr2_no_controllers.launch:

ros@ros-K401UB:~/research/gps$ roslaunch pr2_gazebo pr2_no_controllers.launch 
... logging to /home/ros/.ros/log/751a586e-bd85-11e7-a646-9c5c8ed99f00/roslaunch-ros-K401UB-4556.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.

Traceback (most recent call last):
  File "/opt/ros/indigo/share/xacro/", line 60, in <module>
    import xacro
  File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/", line 36, in <module>
    import glob
ModuleNotFoundError: No module named 'glob'

while processing /opt/ros/indigo/share/pr2_description/robots/upload_pr2.launch:
Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/indigo/share/xacro/ '/opt/ros/indigo/share/pr2_description/robots/pr2.urdf.xacro'] returned with code [1]. 

Param xml is <param command="$(find xacro)/ '$(find pr2_description)/robots/pr2.urdf.xacro'" name="robot_description"/>
The traceback for the exception was written to the log file

However, I can import glob in python2.7:

ros@ros-K401UB:~/research/gps$ python2.7
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import glob

Also, I can locate it under /usr/lib/python2.7:

ros@ros-K401UB:/usr/lib/python2.7$ ls | grep glo

Thus, I guess that the problem occurs because the python executable which runs can't locate the module glob in its path. So I tried to append /usr/lib/python2.7 to my PYTHONPATH, but this doesn't work.

Does anyone know how to solve this issue? Thanks for any suggestion : )

P.S. I am using Ubuntu 14.04+ROS Indigo, and my python -m site output this:

ros@ros-K401UB:~/research/gps$ python -m site
sys.path = [
USER_BASE: '/home/ros/.local' (exists)
USER_SITE: '/home/ros/.local/lib/python3.6/site-packages' (doesn't exist)


edit retag flag offensive close merge delete



Seems to me like you have more than one Python version. Why did you specifically type python2.7 when testing for glob and then python in other tests? Are you sure they are the same Python? Can you try disabling conda and then running your launch file?

jarvisschultz gravatar image jarvisschultz  ( 2017-10-30 12:24:52 -0500 )edit

What do which python and which python2.7 return?

jarvisschultz gravatar image jarvisschultz  ( 2017-10-30 12:25:17 -0500 )edit

I think ROS does not support Python 3, so you might want to start from there. Also, I've had many issues while trying to use Miniconda/Anaconda with ROS, so when I need to use ROS I just comment it out from my .bashrc

bpinaya gravatar image bpinaya  ( 2017-10-30 13:48:49 -0500 )edit

Thanks to both of you jarvisschultz & bpinaya!!! The problem is caused by miniconda, I'll leave the result in the answer.

Po-Jen Lai gravatar image Po-Jen Lai  ( 2017-10-30 20:09:11 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-30 20:09:49 -0500

updated 2017-10-30 20:10:23 -0500

Based on the advice from jarvisschultz & bpinaya, I removed the miniconda/anaconda part in ~/.basrc:

# added by Miniconda3 4.3.21 installer
#export PATH="/home/ros/miniconda3/bin:$PATH"

And after that, I can successfully roslaunch pr2_gazebo pr2_no_controllers.launch, and the output of python -m site became:

sys.path = [
USER_BASE: '/home/ros/.local' (exists)
USER_SITE: '/home/ros/.local/lib/python2.7/site-packages' (doesn't exist)

This problem is solved.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-10-30 10:34:22 -0500

Seen: 4,110 times

Last updated: Oct 30 '17