Python Import Analyser
Lists every import in a module, sorts them by origin, and counts how often each name is used.
Loading the tool…
How to use this tool
- Paste the module, or load a .py file with the picker.
- Select Analyse the imports.
- Check any row with a use count of zero — it is a candidate for removal, not a certainty, since an import can exist for a side effect.
- Turn on the filter to see only the rows worth a second look.
What python import analyser does
Imports accumulate. A module that started with three grows to twenty, half of them left behind by code that moved elsewhere, and nothing in the language complains. This page reads the import statements — both forms, including aliases, multi-name imports and parenthesised lists spanning several lines — and counts how often each bound name appears in the rest of the file.
Two things get called out. A count of zero means the name is never referenced again, which usually means the import can go — usually, not always, because an import can exist for a side effect or to re-export a name, so the page suggests rather than asserts. A star import is flagged differently: it brings in an unknown set of names, so nothing here, or in your editor, or in a reader's head, can be sure what is in scope below it. Every import is also marked as standard library, relative, or third party, which is the split that tells you where your dependencies actually are.