# pydoc > imp

---
type: CommandReference
command: imp
mode: pydoc
section: ""
source: pydoc3
---

## Quick Reference (deprecated; use importlib)
- `imp.acquire_lock()` — Acquire the interpreter’s import lock for thread safety.
- `imp.release_lock()` — Release the import lock.
- `imp.lock_held()` — Return `True` if the import lock is currently held.
- `imp.find_module(name, path)` — **DEPRECATED** Search for a module; returns `(file, pathname, description)`.
- `imp.load_module(name, file, pathname, description)` — **DEPRECATED** Load the module found by `find_module`.
- `imp.get_suffixes()` — **DEPRECATED** Return list of suffixes for importable modules.
- `imp.cache_from_source(path)` — **DEPRECATED** Return the `.pyc` file path for a `.py` source.
- `imp.is_builtin(name)` — Return `True` for built-in module names.

## Name
`imp` — Deprecated module for building custom import hooks (use `importlib`).

## Synopsis
python
import imp
This module provides components for writing a custom `__import__` function. Almost all functions are deprecated in favor of `importlib`.

## Functions

### Lock management
- `acquire_lock()` — Acquire the interpreter’s import lock. Does nothing on platforms without threads.
- `release_lock()` — Release the import lock. Does nothing on platforms without threads.
- `lock_held()` — Return `True` if the import lock is currently held, else `False`. Always returns `False` on platforms without threads.

### Module search and loading
- `find_module(name, path)` — **DEPRECATED** Search for a module. If `path` is omitted or `None`, search for a built‑in, frozen or special module, then continue in `sys.path`. The module name cannot contain `'.'`; to search for a submodule of a package, pass the submodule name and the package’s `__path__`.
- `load_module(name, file, pathname, description)` — **DEPRECATED** Load a module using the information returned by `find_module()`. The module name must include the full package name, if any.
- `load_source(name, pathname, file)` — Load a module from source.
- `load_compiled(name, pathname, file)` — **DEPRECATED** Load a compiled module.
- `load_dynamic(name, pathname, file)` — **DEPRECATED** Load an extension module.
- `load_package(name, path)` — **DEPRECATED** Load a package.
- `new_module(name)` — **DEPRECATED** Create a new module object. The module is not added to `sys.modules`.
- `reload(module)` — **DEPRECATED** Reload the module. The module must have been successfully imported before.

### Built‑in and frozen module checks
- `is_builtin(name)` — Return `True` if the name corresponds to a built‑in module.
- `is_frozen(name)` — Return `True` if the name corresponds to a frozen module.
- `is_frozen_package(name)` — Return `True` if the name is a frozen package.
- `init_builtin(name)` — **DEPRECATED** Load and return a built‑in module by name, or `None` if it does not exist.
- `init_frozen(name)` — Initialize a frozen module.
- `get_frozen_object(name)` — Create a code object for a frozen module.

### Suffix, tag, and cache utilities
- `get_suffixes()` — **DEPRECATED** Return a list of `(suffix, mode, type)` tuples describing the importable file suffixes.
- `get_tag()` — Return the magic tag for `.pyc` files.
- `get_magic()` — **DEPRECATED** Return the magic number for `.pyc` files.
- `cache_from_source(path, debug_override=None)` — **DEPRECATED** Given a `.py` file path, return the path to its `.pyc` file. If `debug_override` is not `None`, it must be a boolean and is used in place of `sys.flags.optimize`. Raises `NotImplementedError` if `sys.implementation.cache_tag` is `None`.
- `source_from_cache(path)` — **DEPRECATED** Given a `.pyc` file path, return the path to its `.py` file. Raises `ValueError` if the path does not conform to PEP 3147 format, and `NotImplementedError` if `sys.implementation.cache_tag` is `None`.

### Other
- `create_dynamic(spec, file=None)` — Create an extension module.

## Classes

### `NullImporter`
**DEPRECATED** — Null import object.

- `__init__(self, path)` — Initialize the object.
- `find_module(self, fullname)` — Always returns `None`.

## Data
- `C_BUILTIN = 6`
- `C_EXTENSION = 3`
- `IMP_HOOK = 9`
- `PKG_DIRECTORY = 5`
- `PY_CODERESOURCE = 8`
- `PY_COMPILED = 2`
- `PY_FROZEN = 7`
- `PY_RESOURCE = 4`
- `PY_SOURCE = 1`
- `SEARCH_ERROR = 0`

## See Also
- [importlib — The implementation of the import statement](https://docs.python.org/3/library/importlib.html)
- [imp module reference](https://docs.python.org/3.10/library/imp.html)