pipreqs
pipreqs copied to clipboard
Pipreqs does not pick up on google-cloud-translate
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
-
Create new python file
-
Import google translate via:
from google.cloud import translate
- run pipreqs
- The package will not be found in the requirements.txt
I found the same issue with the module google-cloud-secret-manager
, which is imported similarly: from google.cloud import secretmanager
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
on windows 10, pipreqs missing from google.cloud import secretmanager
also import protobuf. thanks in advance
Same issue of Mac OS when importing GCS
from google.cloud import storage
pipreq recommends protobuf==3.17.3
For me all imports from google.* are not recognized.
Any news on this? Same issue for me when import BigQuery:
from google.cloud import bigquery
pipreq recommends protobuf==3.19.1
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 theprotobuf
issue for google libraries users.