bndr / pipreqs

pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pipreqs reporting same module with two versions

soulphish opened this issue · comments

I ran pipreqs for the first time, and after fixing some syntax errors it found in my code, it spat out a shorter list than I expected (haven't confirmed anything is missing yet), but what really caught my attention was it repeated two modules with two versions.

Output:

GitPython==3.1.40
GitPython==3.1.41
jsonpickle==3.0.2
numpy==1.26.4
openpyxl==3.1.2
pandas==2.2.0
platformdirs==4.2.0
PyQt5==5.15.10
PyQt5_sip==12.13.0
PySide6==6.6.0
PySide6==6.6.1
PySide6_Addons==6.6.0
PySide6_Essentials==6.6.0
Requests==2.31.0

As you can see, GitPython and PySide6 are both repeated with slightly differing versions.

Output from the terminal:

PS C:\FolderName> pipreqs --force
WARNING: Import named "GitPython" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "GitPython" was resolved to "GitPython:3.1.41" package (https://pypi.org/project/GitPython/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
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.0" package (https://pypi.org/project/pandas/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
WARNING: Import named "platformdirs" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "platformdirs" was resolved to "platformdirs:4.2.0" package (https://pypi.org/project/platformdirs/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
WARNING: Import named "PyQt5" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "PyQt5" was resolved to "PyQt5:5.15.10" package (https://pypi.org/project/PyQt5/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
WARNING: Import named "PySide6" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "PySide6" was resolved to "PySide6:6.6.1" package (https://pypi.org/project/PySide6/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
WARNING: Import named "Requests" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "Requests" was resolved to "requests:2.31.0" package (https://pypi.org/project/requests/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
INFO: Successfully saved requirements file in C:\FolderName\requirements.txt

While it does say "Please, verify manually the final list of requirements.txt to avoid possible dependency confusions." this is repeated for every version it found, so this is not a useful warning. These warnings seem more like normal operation too, not a warning.

I have a similar issue to the one above, although mine is only for 1 and the version difference is larger than ..1

I have same problem numpy is reported twice.

matplotlib==3.8.2
numpy==1.24.1
numpy==1.21.5
pandas==2.2.2

It should give 1.24.1 which is installed in global. 1.21.5 is in a conda environment that is not even activated

I identified where the problem is. pipreqs will check all directories in sys.path. You can check with

import sys
print(sys.path)

Sometimes you have different versions of packages but python will only use one of them. However pipreqs will report all of them. The fix is easy: just delete the ones not in use.

commented

I identified where the problem is. pipreqs will check all directories in sys.path. You can check with

import sys
print(sys.path)

Sometimes you have different versions of packages but python will only use one of them. However pipreqs will report all of them. The fix is easy: just delete the ones not in use.

Can the actions be done by pipreqs?