Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipreqs reports wrong version when package name != module name #265

Open
kelsey-sorrels-tagcg opened this issue Jun 25, 2021 · 0 comments
Open

Comments

@kelsey-sorrels-tagcg
Copy link

Steps to reproduce:

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.

janschmid added a commit to janschmid/pipreqs that referenced this issue Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant