pip freeze
它生成的 requirements.txt 文件包含当前环境的完全列表,不相关的依赖包也会包含进来。
pip install pipreqs
pipreqs --force
只会包含项目 imports 的包,包含列表不是很完全
pip install pigar
输出信息比 pipgreqs 详细
-h, --help show this help message and exit
-v, --version show pigar version information and exit
-u, --update update database, use it when pigar failed you, exit when
action done
-s NAME [NAME ...] search package name by import name, use it if you do not
know import name come from which package, exit when
action done
-c [PATH] check requirements for the latest version. If file path
not given, search *requirements.txt in current
directory, if not found, generate file requirements.txt,
exit when action done
-l LOG_LEVEL show given level log messages, argument can be (ERROR,
WARNING, INFO), case-insensitive
-i DIR [DIR ...] given a list of directory to ignore, relative directory,
*used for* -c and default action
-p SAVE_PATH save requirements in given file path, *used for* default
action
-P PROJECT_PATH project path, which is directory, *used for* default
action