Open evanxlao opened 1 year ago
The same issue in MacOS Sonoma 14.0. Python3 managed by Anaconda3.
$ pipreqs --print
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.0" 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.1.1" package (https://pypi.org/project/pandas/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
WARNING: Import named "PyYAML" not found locally. Trying to resolve it at the PyPI server.
WARNING: Import named "PyYAML" was resolved to "PyYAML:6.0.1" package (https://pypi.org/project/PyYAML/).
Please, verify manually the final list of requirements.txt to avoid possible dependency confusions.
ase==3.22.1
matplotlib==3.8.0
numpy==1.26.0
pandas==2.1.1
pymatgen==2023.9.10
pytest==7.4.2
PyYAML==6.0.1
PyYAML==6.0.1
tqdm==4.66.1
INFO: Successfully output requirements
$ uname -a
Darwin Yang-MacMini 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:42:57 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8112 arm64
This is still (Sep 2024) an issue in 0.4.13. A couple of workarounds to automate cleanup:
pipreqs
, use sort -u
or uniq
. Eg on Ubuntu one can run sort -u -o requirements.txt requirements.txt
pipreqs --print | uniq > requirements.txt
. This can easily be aliased in your .bashrc
. In my .bashrc
I have alias pipreqs="pipreqs --force --print | uniq > requirements.txt; echo 'Created requirements.txt'"
which for me is safe (despite --force
) because all my requirements.txt
are always under version control.
If you want to be able to pass additional options to pipreqs
, create a pipreqs()
command instead of an alias:
pipreqs() {
# Check if the first argument is --help
if [ "$1" = "--help" ]; then
command pipreqs "$@"
return
fi
local exists="Created"
if [ -f requirements.txt ]; then
exists="Overwrote"
fi
command pipreqs --print "$@" | sort -u > requirements.txt
echo "$exists requirements.txt"
}
Note this is actually equivalent to having --force
.
pipreqs --print
output:meanwhile:
tried using
pipreqs --clean requirements.txt --force
, but it actually does not clean it