Instead with pip freeze, where you create a requirements file with all package dependencies or all packages in environment, you can use the following to only write out the packages you use in project:
pipreqs --savepath=requirements.in && pip-compile
See link below for more information: https://stackoverflow.com/questions/31684375/automatically-create-file-requirements-txt