[Python] NameError: name 'glob' is not defined. Did you forget to import 'glob'?

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    Can someone help me please. I am trying to run the following code, but I keep getting an error message.

    import numpy
    import pandas as pd
    from glob import glob
    from selenium import webdriver
    from keras.models import load_model
    import comprasnet_captcha_breaker as ccb

    OUTPUT_FOLDER = 'atas'
    SUPPLEMENTARY_OUTPUT_FOLDER = 'atas_comp'
    SCRAPE_SUPPLEMENTARY_RECORDS = True

    # Loading models
    model_filenames = sorted(glob('models/*.hdf5'))
    labels_filenames = sorted(glob('models/labels/*.dat'))
    ...


    The error I get is the following:

    Traceback (most recent call last):
    File "c:\Users\...\tempCodeRunnerFile.py", line 2, in <module>
    model_filenames = sorted(glob('models/*.hdf5'))
    ^^^^
    NameError: name 'glob' is not defined. Did you forget to import 'glob'?


    If more information is needed please let me know.

    EDIT:

    When I run

    import glob


    or

    from glob import glob


    the code works just fine. But when I try to run the glob function, it breaks.

    Continue reading...

Compartilhe esta Página