How to install the 'glob' module?

99,620

Solution 1

For python 2.7:

pip install glob2

For python 3.7:

pip3 install glob2

Solution 2

For Python 3, there is no glob3.

So use:

sudo pip3 install glob2
Share:
99,620

Related videos on Youtube

Omar Amr
Author by

Omar Amr

Updated on July 09, 2022

Comments

  • Omar Amr
    Omar Amr almost 2 years

    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
    
    • Ry-
      Ry- about 7 years
      glob is a standard module. Which version of Python are you using?
    • Omar Amr
      Omar Amr about 7 years
      Python 3.5.2 Some solutions recommended reinstalling Ubuntu, but i'm keeping that as plan B.
    • wim
      wim about 7 years
      Please include the output of python -m site
    • Omar Amr
      Omar Amr about 7 years
      @wim I added it to the question
    • AmiNadimi
      AmiNadimi over 3 years
      glob is part of the Standard Library in Python so you do not need to install it
    • Admin
      Admin almost 3 years
      The accepted answer is wrong. See the comments on the accepted answer.
  • Skyler Wiernik
    Skyler Wiernik about 4 years
    You really shouldn't sudo install packages for security purposes.
  • J. Tylka
    J. Tylka over 3 years
    even for pip3 it's still glob2, not glob3 :-D
  • Admin
    Admin almost 3 years
    You should not do sudo pip install. pip3 install package_name works fine.
  • PeJota
    PeJota almost 3 years
    @SkylerWiernik what are the security concerns of using sudo for installation?
  • Skyler Wiernik
    Skyler Wiernik almost 3 years
    @PedroMartinez you are giving the installation scripts of the package you are installing route access. If you were to install a malicious package (through something such as a type-o) you could potentially give hackers full access to your entire machine.
  • gshpychka
    gshpychka over 2 years
    You shouldn't sudo install anything, that's a bad practice and a security risk.
  • JavadMH13
    JavadMH13 over 2 years
    I try that on some distributions and get (Access Denied) Error.