# How to fix ImportError: attempted relative import with no known parent package

You ran a file that uses relative imports (`from . import x`) directly as a script, so Python does not know its package. Run it as a module from the project root: `python -m package.module` instead of `python package/module.py`. Or convert the relative imports to absolute ones.

## The exact error

```text
ImportError: attempted relative import with no known parent package
```

## Fix it

1. From the project root (where the top package dir lives), run `python -m package.module`.
   Expected: relative imports resolve

2. Alternative: rewrite `from .helpers import f` as `from package.helpers import f`.
   Expected: works however it is launched

3. Check every package dir has an __init__.py (namespace packages aside).
   Expected: package structure recognized

## When this applies

running a module file directly that contains `from .` / `from ..` imports

## When this does NOT apply

absolute imports failing (that is ModuleNotFoundError, different fix)

## Versions

any Python 3

## Why it happens

Relative imports need the module's package context; direct script execution leaves __package__ unset.

## Edge cases

`python -m` adds the CWD to sys.path; running from the wrong directory still fails.
