Is there any easy way to delete no-more-using packages from requirements file?
I wrote a bash script for this task but, it doesn\'t work as I expect
The best bet is to use a (fresh) python virtual-env with no packages, or only those you definitely know you need, test your package - installing missing packages with pip as you hit problems which should be quite quick for most software then use the pip freeze command to list the packages you really need. Better you you could use pip wheel to create a wheel with the packages in.
The other approach would be to:
Note that for any dependency checking to work well it is advisable to avoid conditional import and import within functions.
Also note that to be sure you have everything then it is a good idea to build a new virtual-env and install from your dependencies list then re-test your code.