python3 -m venv testenv
source testenv/bin/activate
# install older version of scikit-learn
pip install pipreqs scikit-learn==0.20.3
mkdir test
echo "import sklearn" > test/test.py
pipreqs test
cat test/requirements.txt
deactivate
Actual Output
scikit_learn==0.24.2
Expected Output
scikit_learn==0.20.3
This occurs because get_import_local is called with package names in the imports parameter (by way of candidates = get_pkg_names(candidates)). It tests if each import is in local. However, local is a dict where the keys are module names. This results in not finding the locally installed package and instead looking up the latest version on pypi.org.
Steps to reproduce:
Actual Output
scikit_learn==0.24.2
Expected Output
scikit_learn==0.20.3
This occurs because
get_import_local
is called with package names in theimports
parameter (by way ofcandidates = get_pkg_names(candidates)
). It tests if each import is inlocal
. However,local
is a dict where the keys are module names. This results in not finding the locally installed package and instead looking up the latest version on pypi.org.