import-parent
https://import-parent.readthedocs.io/
import_parent is a tiny helper for Python projects that need to import code
from a parent directory.
It adds a parent folder to sys.path relative to the caller, which is useful
for local tooling, test helpers, and small scripts that are not installed as
packages.
It works when used in .py files or .ipynb files, which typically have different default behaviour about local imports otherwise.
Why this package exists
If your project layout is:
project/
├── helper/
├── tests/
└── scripts/
and a file in scripts/ (or any of its subfolders) needs to import a function from helpers/ (or any of its subfolders), this package makes that import possible.
The relative import may be possible on some computers by running from ..helper.file import function, but that .. notation is not possible in cloud-based IDEs like Posit Workbench, Posit Cloud, JupyterHub, GitHub Codespaces, etc., especailly when they are accessed from an enterprise account.
Using add_parent_to_path avoids the need for the following janky modification of sys.path otherwise needed to add a parent directory:
import os
import sys
up_one_level = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if up_one_level not in sys.path:
sys.path.append(up_one_level)
Heaven forbid you need to go up two levels, in which case that janky code gets even jankier.
Installation
pip install import-parent
Quick start
from import_parent import add_parent_to_path
add_parent_to_path("..")
This resolves the parent directory of the current caller and prepends it to
sys.path, so sibling modules can be imported immediately.
When to use it
Use this package when:
- you are working on local scripts or tests that should import a sibling package;
- you want a small, explicit alternative to repeated
sys.pathmanipulation; - you prefer not to install the project in editable mode for every experiment.
Documentation
- Read the Docs: https://import-parent.readthedocs.io/
- Tutorials: see the getting-started guide in the docs.
- How-to recipes: use the task-focused examples in the docs.
- Explanation: learn why this helper exists and when it is appropriate.
- Reference: API details for
add_parent_to_path.
Notes
- The package name on PyPI is
import-parent(with a hyphen). - The Python import name is
import_parent(with an underscore).
Questions and feedback: https://github.com/michaelboerman/import_parent/issues
Metadata
Release files for import-parent 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| import_parent-1.1.0.tar.gz | 3.4 kB | With provenance | Details for import_parent-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| import_parent-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for import_parent-1.1.0-py3-none-any.whl |
Total release size: 6.6 kB
Release files / import_parent-1.1.0.tar.gz
| Download URL | import_parent-1.1.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0a7734486b53f0c4acb2cd736d7eef8e1a2a71ceb9285b77aee68392f24c237
|
|
BLAKE2b-256 checksum How to use checksums |
b28c000ef15321dee30eab420a6428ebbdcfc0859e4363f9b4e14e3cc02dfefd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.
Transparency logRelease files / import_parent-1.1.0-py3-none-any.whl
| Download URL | import_parent-1.1.0-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ee040686a13e2a59992dbd63d6efd6ec2e4c0c1f82dedf26f043d796ada66e0
|
|
BLAKE2b-256 checksum How to use checksums |
9ab12d843bd211a3e9f823c64fe10e6eeb947ae25122b13dfb27e4a1a612fd15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.
Transparency logSecurity for import-parent 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for import_parent-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.