通过freeze
pip freeze > requirements.txt
缺点:
- pip freeze saves all packages in the environment including those that you don’t use in your current project. (if you don’t have virtualenv)
- pip freeze only saves the packages that are installed with pip install in your environment.
- sometimes you just need to create requirements.txt for a new project without installing modules.
pipreqs
$ pip install pipreqs
$ pipreqs /path/to/project
install
pip install -r requirements.txt