pip freeze > requirements.txt
but as above is gathering all dependent libraries as well, better to use underneath:
https://betterdatascience.com/python-pipreqs/
pip install pipreqs
pipreqs . --ignore bin,etc,include,lib,lib64 --force
Keep in mind that using this will not scan for jupyter notebooks (so only looks at python files)