'How to install the 'glob' module?

I am running ubuntu 14.04 and trying to launch ROS Simulator. I have this error:

ImportError: No module named 'glob'

Installing glob2 does not solve the problem.

python -m site output:

sys.path = [
    '/home/omar',
    '/opt/ros/indigo/lib/python2.7/dist-packages',
    '/home/omar/anaconda3/lib/python35.zip',
    '/home/omar/anaconda3/lib/python3.5',
    '/home/omar/anaconda3/lib/python3.5/plat-linux',
    '/home/omar/anaconda3/lib/python3.5/lib-dynload',
    '/home/omar/anaconda3/lib/python3.5/site-packages',
    '/home/omar/anaconda3/lib/python3.5/site-packages/Sphinx-1.4.6-py3.5.egg',
    '/home/omar/anaconda3/lib/python3.5/site-packages/numba-0.29.0-py3.5-linux-x86_64.egg',
    '/home/omar/anaconda3/lib/python3.5/site-packages/glob2-0.4.1-py3.5.egg',
    '/home/omar/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg',
]
USER_BASE: '/home/omar/.local' (exists)
USER_SITE: '/home/omar/.local/lib/python3.5/site-packages' (doesn't exist)
ENABLE_USER_SITE: True


Solution 1:[1]

For python 2.7:

pip install glob2

For python 3.7:

pip3 install glob2

Solution 2:[2]

For Python 3, there is no glob3.

So use:

sudo pip3 install glob2

Solution 3:[3]

ROS does not support Python 3 in the first place, so I would not recommend you use it. You should install 2.7.

Redownload it: https://www.python.org/downloads/

Here's the source for glob: https://docs.python.org/2/library/glob.html

As you can see it's in the Lib package which marks it as standard

Solution 4:[4]

In Python version 3.10, the glob module is included in the standard module list. It means you do not need to install it.

You might be facing this error because you are using any prior version of python.

In this case use

pip3 install glob2

But make sure you have to import it using

import glob 
# not import glob2

Hope this helped.

Happy Globbing.

Solution 5:[5]

if you use Linux Distributions write this command:

sudo pip install glob2

for python 3:

sudo pip3 install glob2 

and if you using Windows: open a command prompt and write this command:

pip install glob2

for python 3:

pip3 install glob

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Tonechas
Solution 3 cjds
Solution 4 AlixaProDev
Solution 5 JavadMH13