pipreqs icon indicating copy to clipboard operation
pipreqs copied to clipboard

Pipreqs does not pick up on google-cloud-translate

Open hojlind opened this issue 5 years ago • 7 comments

Pipreqs does not seem to be able to infer the google-cloud-translate package from the import that is suggested in the package instructions (from google.cloud import translate).

Operating system and version

WSL 1.0 running Ubuntu on Windows 10 Python 3.6.9

Steps to reproduce

  1. Create new python file

  2. Import google translate via:

from google.cloud import translate
  1. run pipreqs
  2. The package will not be found in the requirements.txt

hojlind avatar Jan 17 '20 09:01 hojlind

I found the same issue with the module google-cloud-secret-manager, which is imported similarly: from google.cloud import secretmanager

alfonsomhc avatar Nov 24 '20 20:11 alfonsomhc

Same here

from google.cloud import datastore

DEBUG: Found packages: {'google'} DEBUG: Found imports: protobuf

It seems to recognise google but uses protobuf as a requirement instead.

Interestingly, if you type import google and go to the reference for google, the path is .vscode\extensions\ms-python.vscode-pylance-2021.3.3\dist\typeshed-fallback\stubs\protobuf\google\__init__.pyi

I've tried removing pylance as the language server but this still happens

requirements.txt

expected: google-cloud-datastore==1.13.0 actual: protobuf==3.15.6

chrissyast avatar Mar 30 '21 18:03 chrissyast

on windows 10, pipreqs missing from google.cloud import secretmanager

also import protobuf. thanks in advance

RentingCol avatar Apr 27 '21 16:04 RentingCol

Same issue of Mac OS when importing GCS from google.cloud import storage

pipreq recommends protobuf==3.17.3

octopop avatar Jul 14 '21 07:07 octopop

For me all imports from google.* are not recognized.

yannick-vinkesteijn avatar Oct 19 '21 12:10 yannick-vinkesteijn

Any news on this? Same issue for me when import BigQuery: from google.cloud import bigquery pipreq recommends protobuf==3.19.1

ebonura-fastly avatar Nov 14 '21 10:11 ebonura-fastly

Yes I confirm that every package with '.' in the name is not discovered. For example it is the case for the opentelemetry SDK as well. Reading rapidly the code, I found maybe some lines to change to fix that. Unfortunately, I don't have time to check and propose a Pull Request ... I put here the result of my investigation if someone is interested.

  • Changing this line to create one raw_import by name being with value "{{module}}.{{name}}" https://github.com/bndr/pipreqs/blob/v0.4.11/pipreqs/pipreqs.py#L123
  • Removing this guard here https://github.com/bndr/pipreqs/blob/v0.4.11/pipreqs/pipreqs.py#L140.
  • As the guard is removed, I assume the code should check all the different combinations there https://github.com/bndr/pipreqs/blob/v0.4.11/pipreqs/pipreqs.py#L177 I assume here that doing a search from the bottom (aaa.bbb.ccc.ddd, aaa.bbb.ccc, ...) would hopefully find less issues than doing the search from the top (aaa, aaa.bbb, ...) that would lead to the protobuf issue for google libraries users.

celian-garcia avatar Feb 11 '22 13:02 celian-garcia