Advertisements
I want to check all the packages that are being used by my python script. I have a list of imports at the top of the script, but I’m not sure if those packages are actually getting used. So I want to check, of all the commands/functions I am using within by script, which of my imports are being used.
For example in the sample below I am only using the pandas package but I am importing numpy as well:
import pandas as pd
import numpy as np
data = pd.read_csv("/path/to/file.csv")
I want to be able to get back a result of just pandas
since that is the only package that is getting used.
All the solutions I’ve seen will just get all the packages that are imported.
>Solution :
Use vulture
to find unused imports. Install it:
pip install vulture
vulture your_script.py