pipreqs icon indicating copy to clipboard operation
pipreqs copied to clipboard

Pipreqs adds wrong package to requirements.txt

Open artemgur opened this issue 1 year ago • 7 comments

In my project, I use kafka-python package. When pipreqs generates requirements.txt, it adds kafka package in addition to kafka-python package. kafka package is not used in the project, it's not even installed.

artemgur avatar Mar 01 '23 09:03 artemgur

I have the same problem.

Arfius avatar Mar 01 '23 16:03 Arfius

I suppose pipreqs doesn't support hyphenated packages yet.

p4r4xor avatar Mar 14 '23 07:03 p4r4xor

I have similar issue with azure-storage. It adds azure-storage==0.37, which is deprecated and cannot be installed instead of azure-storage-blob==12.15.0, that is actually installed and used. Is there a workaround for this or should I switch back to pip freeze to create requirements files?

Godd67 avatar Mar 16 '23 19:03 Godd67

It looks like the same problem as sklearn not correctly formed

CwjXFH avatar Mar 23 '23 01:03 CwjXFH

It adds azure-storage==0.37, which is deprecated and cannot be installed instead of azure-storage-blob==12.15.0, that is actually installed and used. Is there a workaround for this or should I switch back to pip freeze to create requirements files?

I'm having the same issue with azure related modules. It seems like there are a few assumptions in the package deduction that are getting in the way.

  1. For azure specifically, there are multiple entries in the mapping with the 'azure' key. Meaning that subsequent entries for 'azure' will overwrite previous entries. Hence, why azure-storage is showing up.
  2. The get_all_imports function assumes that we only want the top-level module. They give the example django.conf should only import django. This assumption is broken for several of the azure modules, eg azure.functions actually should point to the azure-functions project.

Currently I don't have a great proposal for how to redesign the mapping between module imports and pypi project names. I think this is a recurring issue that the maintainers have identified. My current thought is there may be a way to programatically generate the mapping file by queries to the pypi package api, though I don't have a working prototype yet.

kevindugan avatar Mar 23 '23 10:03 kevindugan

I had the same problem. I have a private python module locates in folder lib, then pipreqs added lib into requirement.txt while this lib acctully refers to https://pypi.org/project/lib/ and confused users that install with this txt file.

fs34a avatar Jun 28 '23 21:06 fs34a

I had the same problem. I have a private python module locates in folder lib, then pipreqs added lib into requirement.txt while this lib acctully refers to https://pypi.org/project/lib/ and confused users that install with this txt file.

I am building an internal proof of concept python monorepo tool and get the same thing but with pkg instead of lib.

At least in my case using the --use-local flag to only use what I have installed locally to build the requirements.txt file without the rogue reference.

bobfirestone avatar Jul 28 '23 19:07 bobfirestone