{
    "mode": "pydoc",
    "parameter": "pkgutil",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/pkgutil/json",
    "generated": "2026-11-21T14:35:53Z",
    "sections": {
        "NAME": {
            "content": "pkgutil - Utilities to support packages.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.12/library/pkgutil.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.tuple(builtins.object)\nModuleInfo\n",
            "subsections": [
                {
                    "name": "class ModuleInfo",
                    "content": "|  ModuleInfo(modulefinder, name, ispkg)\n|\n|  A namedtuple with minimal info about a module.\n|\n|  Method resolution order:\n|      ModuleInfo\n|      builtins.tuple\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  getnewargs(self) from collections.ModuleInfo\n|      Return self as a plain tuple.  Used by copy and pickle.\n|\n|  repr(self) from collections.ModuleInfo\n|      Return a nicely formatted representation string\n|\n|  asdict(self) from collections.ModuleInfo\n|      Return a new dict which maps field names to their values.\n|\n|  replace(self, /, kwds) from collections.ModuleInfo\n|      Return a new ModuleInfo object replacing specified fields with new values\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  make(iterable) from collections.ModuleInfo\n|      Make a new ModuleInfo object from a sequence or iterable\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(cls, modulefinder, name, ispkg) from namedtupleModuleInfo.ModuleInfo\n|      Create new instance of ModuleInfo(modulefinder, name, ispkg)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  modulefinder\n|      Alias for field number 0\n|\n|  name\n|      Alias for field number 1\n|\n|  ispkg\n|      Alias for field number 2\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  matchargs = ('modulefinder', 'name', 'ispkg')\n|\n|  fielddefaults = {}\n|\n|  fields = ('modulefinder', 'name', 'ispkg')\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.tuple:\n|\n|  add(self, value, /)\n|      Return self+value.\n|\n|  contains(self, key, /)\n|      Return bool(key in self).\n|\n|  eq(self, value, /)\n|      Return self==value.\n|\n|  ge(self, value, /)\n|      Return self>=value.\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  getitem(self, key, /)\n|      Return self[key].\n|\n|  gt(self, value, /)\n|      Return self>value.\n|\n|  hash(self, /)\n|      Return hash(self).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  le(self, value, /)\n|      Return self<=value.\n|\n|  len(self, /)\n|      Return len(self).\n|\n|  lt(self, value, /)\n|      Return self<value.\n|\n|  mul(self, value, /)\n|      Return self*value.\n|\n|  ne(self, value, /)\n|      Return self!=value.\n|\n|  rmul(self, value, /)\n|      Return value*self.\n|\n|  count(self, value, /)\n|      Return number of occurrences of value.\n|\n|  index(self, value, start=0, stop=9223372036854775807, /)\n|      Return first index of value.\n|\n|      Raises ValueError if the value is not present.\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from builtins.tuple:\n|\n|  classgetitem(...)\n|      See PEP 585\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "extend_path",
                    "content": "Extend a package's path.\n\nIntended use is to place the following code in a package's init.py:\n\nfrom pkgutil import extendpath\npath = extendpath(path, name)\n\nFor each directory on sys.path that has a subdirectory that\nmatches the package name, add the subdirectory to the package's\npath.  This is useful if one wants to distribute different\nparts of a single logical package as multiple directories.\n\nIt also looks for *.pkg files beginning where * matches the name\nargument.  This feature is similar to *.pth files (see site.py),\nexcept that it doesn't special-case lines starting with 'import'.\nA *.pkg file is trusted at face value: apart from checking for\nduplicates, all entries found in a *.pkg file are added to the\npath, regardless of whether they are exist the filesystem.  (This\nis a feature.)\n\nIf the input path is not a list (as is the case for frozen\npackages) it is returned unchanged.  The input path is not\nmodified; an extended copy is returned.  Items are only appended\nto the copy at the end.\n\nIt is assumed that sys.path is a sequence.  Items of sys.path that\nare not (unicode or 8-bit) strings referring to existing\ndirectories are ignored.  Unicode items of sys.path that cause\nerrors when used as filenames may cause this function to raise an\nexception (in line with os.path.isdir() behavior).\n"
                },
                {
                    "name": "find_loader",
                    "content": "Find a \"loader\" object for fullname\n\nThis is a backwards compatibility wrapper around\nimportlib.util.findspec that converts most failures to ImportError\nand only returns the loader rather than the full spec\n"
                },
                {
                    "name": "get_data",
                    "content": "Get a resource from a package.\n\nThis is a wrapper round the PEP 302 loader getdata API. The package\nargument should be the name of a package, in standard module format\n(foo.bar). The resource argument should be in the form of a relative\nfilename, using '/' as the path separator. The parent directory name '..'\nis not allowed, and nor is a rooted name (starting with a '/').\n\nThe function returns a binary string, which is the contents of the\nspecified resource.\n\nFor packages located in the filesystem, which have already been imported,\nthis is the rough equivalent of\n\nd = os.path.dirname(sys.modules[package].file)\ndata = open(os.path.join(d, resource), 'rb').read()\n\nIf the package cannot be located or loaded, or it uses a PEP 302 loader\nwhich does not support getdata(), then None is returned.\n"
                },
                {
                    "name": "get_importer",
                    "content": "Retrieve a finder for the given path item\n\nThe returned finder is cached in sys.pathimportercache\nif it was newly created by a path hook.\n\nThe cache (or part of it) can be cleared manually if a\nrescan of sys.pathhooks is necessary.\n"
                },
                {
                    "name": "get_loader",
                    "content": "Get a \"loader\" object for moduleorname\n\nReturns None if the module cannot be found or imported.\nIf the named module is not already imported, its containing package\n(if any) is imported, in order to establish the package path.\n"
                },
                {
                    "name": "iter_importers",
                    "content": "Yield finders for the given module name\n\nIf fullname contains a '.', the finders will be for the package\ncontaining fullname, otherwise they will be all registered top level\nfinders (i.e. those on both sys.metapath and sys.pathhooks).\n\nIf the named module is in a package, that package is imported as a side\neffect of invoking this function.\n\nIf no module name is specified, all top level finders are produced.\n"
                },
                {
                    "name": "iter_modules",
                    "content": "Yields ModuleInfo for all submodules on path,\nor, if path is None, all top-level modules on sys.path.\n\n'path' should be either None or a list of paths to look for\nmodules in.\n\n'prefix' is a string to output on the front of every module name\non output.\n"
                },
                {
                    "name": "read_code",
                    "content": ""
                },
                {
                    "name": "walk_packages",
                    "content": "Yields ModuleInfo for all modules recursively\non path, or, if path is None, all accessible modules.\n\n'path' should be either None or a list of paths to look for\nmodules in.\n\n'prefix' is a string to output on the front of every module name\non output.\n\nNote that this function must import all *packages* (NOT all\nmodules!) on the given path, in order to access the path\nattribute to find submodules.\n\n'onerror' is a function which gets called with one argument (the\nname of the package which was being imported) if any exception\noccurs while trying to import a package.  If no onerror function is\nsupplied, ImportErrors are caught and ignored, while all other\nexceptions are propagated, terminating the search.\n\nExamples:\n\n# list all modules python can access\nwalkpackages()\n\n# list all submodules of ctypes\nwalkpackages(ctypes.path, ctypes.name+'.')\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['getimporter', 'iterimporters', 'getloader', 'findloade...\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.12/pkgutil.py\n\n",
            "subsections": []
        }
    },
    "summary": "pkgutil - Utilities to support packages.",
    "flags": [],
    "examples": [],
    "see_also": []
}