bndr / pipreqs

pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward.
Apache License 2.0
6.38k stars 388 forks source link

BUG: not able to detect local packages #444

Open yfiua opened 6 months ago

yfiua commented 6 months ago

I have pandas installed

> pip list | grep pandas
pandas                        2.2.0

but pipreqs is not able to detect it and tries to resolve it via PyPI. Why?

> pipreqs . --print

INFO: Not scanning for jupyter notebooks.
WARNING: Import named "pandas" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "pandas" was resolved to "pandas:2.2.2" package (https://pypi.org/project/pandas/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
matplotlib==3.8.2
numpy==1.24.1
numpy==1.21.5
pandas==2.2.2
INFO: Successfully output requirements
AhmetZamanis commented 6 months ago

@yfiua I had the same "Not scanning for jupyter notebooks" warning, and around half of the imported packages were missing. You need the following command, which enables scanning of Jupyter notebooks:

pipreqs --scan-notebooks .

After adding this option, I still get the "not found locally" warning for a few packages, but the resulting requirements.txt file is complete and correct, except for the pandas version. I have pandas 2.2.1 installed, but pipreqs lists 2.2.2 in the generated file.

The warning messages I get are below for the devs' reference, if needed:

WARNING: Import named "numpy" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "numpy" was resolved to "numpy:1.26.4" package (https://pypi.org/project/numpy/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
WARNING: Import named "pandas" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "pandas" was resolved to "pandas:2.2.2" package (https://pypi.org/project/pandas/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
WARNING: Import named "seaborn" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "seaborn" was resolved to "seaborn:0.13.2" package (https://pypi.org/project/seaborn/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
INFO: Successfully saved requirements file in .\requirements.txt
yfiua commented 6 months ago

For me it is not related to --scan-notebooks because I have no notebooks. Adding --scan-notebooks does not solve the problem

AhmetZamanis commented 6 months ago

I see, I assumed the warning is only displayed when there are notebooks in the project. My mistake.

sergedv2024 commented 5 months ago

I have the same problem, it recognise well some packages but not polars niether pandas

VishalSharmaCode commented 5 months ago

Use conda install anaconda::pandas command into jupyter command terminal

yfiua commented 5 months ago

Use conda install anaconda::pandas command into jupyter command terminal

The issue is not related to conda, nor jupyter. pipreqs should work without conda or jupyter.

phgas commented 3 months ago

Same issue here, was anyone able to solve it?