Ask Your Question
0

Import error: No module named 'glob'

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

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

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/xacro.py", line 60, in <module>
    import xacro
  File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", 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/xacro.py '/opt/ros/indigo/share/pr2_description/robots/pr2.urdf.xacro'] returned with code [1]. 

Param xml is <param command="$(find xacro)/xacro.py '$(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
glob.py
glob.pyc

Thus, I guess that the problem occurs because the python executable which runs xacro.py 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 = [
    '/home/ros/research/gps',
    '/home/ros/research/tool/rllab',
    '/opt/ros/indigo/lib/python2.7/dist-packages',
    '/usr/lib/python2.7/dist-packages',
    '/home/ros/miniconda3/lib/python36.zip',
    '/home/ros/miniconda3/lib/python3.6',
    '/home/ros/miniconda3/lib/python3.6/lib-dynload',
    '/home/ros/miniconda3/lib/python3.6/site-packages',
    '/home/ros/code/gym',
    '/home/ros/miniconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg',
]
USER_BASE: '/home/ros/.local' (exists)
USER_SITE: '/home/ros/.local/lib/python3.6/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

Reference:

  1. http://forum.erlerobotics.com/t/solve...
  2. https://stackoverflow.com/questions/4...
edit retag flag offensive close merge delete

Comments

1

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 imagejarvisschultz ( 2017-10-30 12:24:52 -0600 )edit

What do which python and which python2.7 return?

jarvisschultz gravatar imagejarvisschultz ( 2017-10-30 12:25:17 -0600 )edit
1

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 imagebpinaya ( 2017-10-30 13:48:49 -0600 )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 imagePo-Jen Lai ( 2017-10-30 20:09:11 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

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

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 = [
    '/usr/lib/python2.7',
    '/usr/local/lib/python2.7/dist-packages/Box2D-2.3.2-py2.7-linux-x86_64.egg',
    '/opt/ros/indigo/lib/python2.7/dist-packages',
    '/usr/lib/python2.7/dist-packages',
    '/usr/lib/python2.7/plat-x86_64-linux-gnu',
    '/usr/lib/python2.7/lib-tk',
    '/usr/lib/python2.7/lib-old',
    '/usr/lib/python2.7/lib-dynload',
    '/usr/local/lib/python2.7/dist-packages',
    '/usr/lib/python2.7/dist-packages/PILcompat',
    '/usr/lib/python2.7/dist-packages/gst-0.10',
    '/usr/lib/python2.7/dist-packages/gtk-2.0',
    '/usr/lib/pymodules/python2.7',
    '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
    '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode',
]
USER_BASE: '/home/ros/.local' (exists)
USER_SITE: '/home/ros/.local/lib/python2.7/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

This problem is solved.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 1,858 times

Last updated: Oct 30 '17