Import error: No module named 'glob'
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:
Seems to me like you have more than one Python version. Why did you specifically type
python2.7
when testing for glob and thenpython
in other tests? Are you sure they are the same Python? Can you try disabling conda and then running your launch file?What do
which python
andwhich python2.7
return?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
Thanks to both of you jarvisschultz & bpinaya!!! The problem is caused by miniconda, I'll leave the result in the answer.