'-' hyphen is replaced with an underscore, '_'
pipreqs --encoding=utf8 . ++++++++++++++++++++++++++++ It appears that pipreqs '-' hyphen is getting replaced with an underscore. Following are the few examples, where pipreqs used an underscore where it should have been '-' opencv_python==4.5.5.64 marshmallow_enum==1.5.1 python_json_logger==2.0.2 scikit_image==0.19.2 scikit_learn==1.0.2
This is due to the lack of hard requirements in regard to python module names. => It is allowed to name your package with hyphens (e.g. "scikit-image"), but since - is a python operator, it is not allowed for use in imports. So the "scikit-image" is actually imported with import scikit_image. And since the pipreqs goes through imports, it collects names with underscores. Also, since it is also possible to name your package with underscores, it is not possible to decide, if the actual package from import is with - or _. There would have to be some checking against PyPI like if <package_name> not on PyPI && <package-name> on PyPI: print with "-" instead of "_" But I would be very careful with this, as it creates an attack surface (you could upload other package with the other char - so both "scikit-image" and "scikit_image" would by available on PyPI).