{
    "mode": "pydoc",
    "parameter": "imp",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/imp/json",
    "generated": "2026-06-02T15:50:23Z",
    "sections": {
        "NAME": {
            "content": "imp\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/imp.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": []
        },
        "DESCRIPTION": {
            "content": "This module provides the components needed to build your own import\nfunction.  Undocumented functions are obsolete.\n\nIn most cases it is preferred you consider using the importlib module's\nfunctionality over this module.\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.object\nNullImporter\n",
            "subsections": [
                {
                    "name": "class NullImporter",
                    "content": "|  NullImporter(path)\n|\n|  DEPRECATED\n|\n|  Null import object.\n|\n|  Methods defined here:\n|\n|  init(self, path)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  findmodule(self, fullname)\n|      Always returns None.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "acquire_lock",
                    "content": "Acquires the interpreter's import lock for the current thread.\n\nThis lock should be used by import hooks to ensure thread-safety when importing\nmodules. On platforms without threads, this function does nothing.\n"
                },
                {
                    "name": "cache_from_source",
                    "content": "DEPRECATED\n\nGiven the path to a .py file, return the path to its .pyc file.\n\nThe .py file does not need to exist; this simply returns the path to the\n.pyc file calculated as if the .py file were imported.\n\nIf debugoverride is not None, then it must be a boolean and is used in\nplace of sys.flags.optimize.\n\nIf sys.implementation.cachetag is None then NotImplementedError is raised.\n"
                },
                {
                    "name": "create_dynamic",
                    "content": "Create an extension module.\n"
                },
                {
                    "name": "find_module",
                    "content": "DEPRECATED\n\nSearch for a module.\n\nIf path is omitted or None, search for a built-in, frozen or special\nmodule and continue search in sys.path. The module name cannot\ncontain '.'; to search for a submodule of a package, pass the\nsubmodule name and the package's path.\n"
                },
                {
                    "name": "get_frozen_object",
                    "content": "Create a code object for a frozen module.\n"
                },
                {
                    "name": "get_magic",
                    "content": "DEPRECATED\n\nReturn the magic number for .pyc files.\n"
                },
                {
                    "name": "get_suffixes",
                    "content": "DEPRECATED\n"
                },
                {
                    "name": "get_tag",
                    "content": "Return the magic tag for .pyc files.\n"
                },
                {
                    "name": "init_builtin",
                    "content": "DEPRECATED\n\nLoad and return a built-in module by name, or None is such module doesn't\nexist\n"
                },
                {
                    "name": "init_frozen",
                    "content": "Initializes a frozen module.\n"
                },
                {
                    "name": "is_builtin",
                    "content": "Returns True if the module name corresponds to a built-in module.\n"
                },
                {
                    "name": "is_frozen",
                    "content": "Returns True if the module name corresponds to a frozen module.\n"
                },
                {
                    "name": "is_frozen_package",
                    "content": "Returns True if the module name is of a frozen package.\n"
                },
                {
                    "name": "load_compiled",
                    "content": "DEPRECATED\n"
                },
                {
                    "name": "load_dynamic",
                    "content": "DEPRECATED\n\nLoad an extension module.\n"
                },
                {
                    "name": "load_module",
                    "content": "DEPRECATED\n\nLoad a module, given information returned by findmodule().\n\nThe module name must include the full package name, if any.\n"
                },
                {
                    "name": "load_package",
                    "content": "DEPRECATED\n"
                },
                {
                    "name": "load_source",
                    "content": ""
                },
                {
                    "name": "lock_held",
                    "content": "Return True if the import lock is currently held, else False.\n\nOn platforms without threads, return False.\n"
                },
                {
                    "name": "new_module",
                    "content": "DEPRECATED\n\nCreate a new module.\n\nThe module is not entered into sys.modules.\n"
                },
                {
                    "name": "release_lock",
                    "content": "Release the interpreter's import lock.\n\nOn platforms without threads, this function does nothing.\n"
                },
                {
                    "name": "reload",
                    "content": "DEPRECATED\n\nReload the module and return it.\n\nThe module must have been successfully imported before.\n"
                },
                {
                    "name": "source_from_cache",
                    "content": "DEPRECATED\n\nGiven the path to a .pyc. file, return the path to its .py file.\n\nThe .pyc file does not need to exist; this simply returns the path to\nthe .py file calculated to correspond to the .pyc file.  If path does\nnot conform to PEP 3147 format, ValueError will be raised. If\nsys.implementation.cachetag is None then NotImplementedError is raised.\n"
                }
            ]
        },
        "DATA": {
            "content": "CBUILTIN = 6\nCEXTENSION = 3\nIMPHOOK = 9\nPKGDIRECTORY = 5\nPYCODERESOURCE = 8\nPYCOMPILED = 2\nPYFROZEN = 7\nPYRESOURCE = 4\nPYSOURCE = 1\nSEARCHERROR = 0\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/imp.py\n\n",
            "subsections": []
        }
    },
    "summary": "imp",
    "flags": [],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "A helper to use native systemd support under WSL (Windows Subsystem for Linux).",
        "examples": [
            {
                "description": "Initialize the helper functions and keep WSL running until explicit shutdown (run once, at start)",
                "command": "imp {{-i|--initialize}}"
            },
            {
                "description": "Run a shell inside a systemd user session",
                "command": "imp {{-s|--shell}}"
            },
            {
                "description": "Run a specified command inside a systemd user session (preserves working directory)",
                "command": "imp {{-c|--command}} {{command}}"
            },
            {
                "description": "Shut down systemd and the WSL instance",
                "command": "imp {{-u|--shutdown}}"
            }
        ]
    }
}