[Python] pkgutil.walk_packages() and pkgutil.iter_modules() only find one package

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have plugins in directories like:

    .
    ./content
    ./content/pageobject/__init__.py
    ./content/staticfiles/__init__.py


    And I use them with:

    import pkgutil

    result = pkgutil.iter_modules( [ 'content' ] )
    for finder, name, ispkg in result:
    print(name)


    and it only prints name pageobject, not both plugins. Both walk_packages() and iter_modules() behave the same. Shouldn't it walk all directories and find everything? This is Python 3.9.21.

    Continue reading...

Compartilhe esta Página