envcore
pip freeze done right — only what your code actually uses.
pip freeze dumps your entire environment — often 200+ packages — most of which your project never touches. pipreqs scans source files but misses dynamic imports, conditional imports, and anything loaded at runtime.
Envcore hooks into Python's import system while your code actually runs, records only what gets imported, and writes a clean manifest. One command rebuilds that exact environment anywhere.
envcore trace train.py → env_manifest.json → envcore restore
No config files to maintain. No guesswork. Ship the manifest with your code.
Install
pip install envcore
Requires Python 3.9+.
Usage
Trace your script:
envcore trace train.py
Traced 3 packages:
numpy 1.26.4
pandas 2.1.4
torch 2.1.0
Manifest saved → env_manifest.json
Restore anywhere:
envcore restore
That's it. The manifest contains only what was actually imported — nothing more.
Why runtime tracing?
Static tools read your source files. They miss:
import torchinside anif cuda_available:block- imports inside functions, called only at runtime
- dynamic
importlib.import_module(...)calls - packages imported by your dependencies on your behalf
Envcore catches all of these because it watches what Python actually loads, not what it might load.
Note: Envcore traces one execution. If your code has branches that aren't hit during tracing (e.g. a
prod-only import), those won't be captured. Trace against a representative run.
Programmatic API
import envcore
envcore.start_tracking()
import numpy
import pandas
from sklearn.model_selection import train_test_split
envcore.stop_tracking()
envcore.snapshot("env_manifest.json")
Context manager:
from envcore import ImportTracer
with ImportTracer() as tracer:
import numpy
import pandas
print(tracer.module_names) # ['numpy', 'pandas']
Decorator:
from envcore import ImportTracer
tracer = ImportTracer()
@tracer
def train():
import torch
import wandb
train()
print(tracer.module_names) # ['torch', 'wandb']
Jupyter Notebooks
envcore notebook analysis.ipynb
Or inside a running notebook:
%load_ext envcore
%envcore start
import numpy, pandas
%envcore snapshot
How it works
1. TRACE builtins.__import__ → ImportTracer hook
Records module name, filters stdlib and pre-existing packages
2. RESOLVE import name → PyPI package + pinned version
"PIL" → Pillow 10.2.0
"cv2" → opencv-python 4.9.0
"sklearn" → scikit-learn 1.4.0
3. MANIFEST env_manifest.json
{ "numpy": "1.26.4", "torch": "2.1.0", ... }
4. RESTORE pip install numpy==1.26.4 torch==2.1.0 ...
Other commands
| Command | What it does |
|---|---|
envcore trace <script> |
Trace a script, save manifest |
envcore restore |
Install packages from manifest |
envcore show |
Print manifest contents |
envcore diff <a> <b> |
Compare two manifests |
envcore export -f <format> |
Export to requirements.txt, pyproject.toml, conda, docker, pipfile, setup.py |
envcore sync |
Diff manifest vs existing requirements.txt |
envcore doctor |
Check for missing, outdated, or orphaned packages |
envcore minimize |
Find the minimal top-level install set |
envcore lock |
Generate lockfile with SHA-256 hashes |
envcore audit |
Scan for vulnerabilities via OSV.dev |
envcore ci |
Exit 0/1 based on whether environment matches manifest |
Every command supports --help. Set NO_COLOR=1 to disable colour output.
Configuration
# pyproject.toml
[tool.envcore]
manifest = "env_manifest.json"
exclude = ["setuptools", "pip", "wheel"]
entry_points = ["src/main.py"]
auto_export = "requirements.txt"
Contributing
git clone https://github.com/JanBremec/envcore.git
cd envcore
pip install -e ".[dev]"
pytest tests/ -v
Issues and PRs welcome.
License
MIT — Jan Bremec
Release files for envcore 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| envcore-0.1.1.tar.gz | 51.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| envcore-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 94.5 kB
Release files / envcore-0.1.1.tar.gz
| Download URL | envcore-0.1.1.tar.gz |
|---|---|
| Size | 51.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc5920878cf8ec138f591acc125fad1106507c94a84604584a95a28f94050479
|
|
BLAKE2b-256 checksum How to use checksums |
8d8b28a74bad8770da3940151167a87e23c815f14efe533e778cbcb5e7c54a04
|
| 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 May 28, 2026.
Transparency logRelease files / envcore-0.1.1-py3-none-any.whl
| Download URL | envcore-0.1.1-py3-none-any.whl |
|---|---|
| Size | 43.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2af9eeccaeadb6452c8d32488d96fe82e8ba69f0c02cfde53322d335c02c11f3
|
|
BLAKE2b-256 checksum How to use checksums |
06e68acf164e51b489fedb198c0eb1b58287f1b4b63c3ba289d23fd8a4282dce
|
| 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 May 28, 2026.
Transparency log