# ModuleNotFoundError: No module named 'package' after pip install --target ./lib package

- **ID:** `python/pip-target-dir-missing-pth`
- **Domain:** python
- **Category:** install_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pip install --target installs into the specified directory but does not add it to sys.path, so Python cannot import the package.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Set PYTHONPATH: export PYTHONPATH=$PWD/lib:$PYTHONPATH
   ```
2. **** (85% success)
   ```
   Add a .pth file in site-packages pointing to the target: echo "/abs/path/to/lib" > $(python -c 'import site; print(site.getsitepackages()[0])')/custom.pth
   ```
3. **** (88% success)
   ```
   At runtime: import sys; sys.path.insert(0, '/abs/path/to/lib')
   ```

## Dead Ends

- **** — Upgrade does not modify sys.path; the import still fails. (90% fail)
- **** — Works interactively but is not persisted to the deployed environment, causing the same error in CI/production. (70% fail)
- **** — --no-deps does not affect sys.path registration. (95% fail)
