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

Why is there "~equests" in result? #242

Closed Mr-Zhen closed 3 years ago

Mr-Zhen commented 3 years ago

pipreqs.exe . --encoding=utf8 --debug --print --no-pin --pypi-server https://pypi.tuna.tsinghua.edu.cn/simple

DEBUG: Found packages: {'ipaddress', 'enum', 'future', 're', 'requests', 'mysql', 'dbutils', 'typing'} DEBUG: Found imports: dbutils, mysql_connector_repackaged, Requests DEBUG: Getting packages information from Local/PyPI DEBUG: Starting new HTTPS connection (1): pypi.tuna.tsinghua.edu.cn:443 DEBUG: https://pypi.tuna.tsinghua.edu.cn:443 "GET /simplemysql_connector_repackaged/json HTTP/1.1" 404 None DEBUG: Package mysql_connector_repackaged does not exist or network problems DEBUG: Starting new HTTPS connection (1): pypi.tuna.tsinghua.edu.cn:443 DEBUG: https://pypi.tuna.tsinghua.edu.cn:443 "GET /simpleRequests/json HTTP/1.1" 404 None DEBUG: Package Requests does not exist or network problems DEBUG: Writing 2 requirements: DBUtils, ~equests to - DBUtils ~equests INFO: Successfully output requirements

pip install -r .\requirements.txt

ERROR: Invalid requirement: '~equests' (from line 2 of .\requirements.txt)

🤔

alan-barzilay commented 3 years ago

Hi! could you provide a minimal setup to reproduce your error? Also, what python version are you using?

Mr-Zhen commented 3 years ago

My python version is 3.8.1

# only one line in the py file import requests

and then run pipreqs.exe . --encoding=utf8 --debug --print --no-pin

DEBUG: Found packages: {'requests'} DEBUG: Found imports: Requests DEBUG: Getting packages information from Local/PyPI DEBUG: Starting new HTTPS connection (1): pypi.python.org:443 DEBUG: https://pypi.python.org:443 "GET /pypi/Requests/json HTTP/1.1" 301 122 DEBUG: Starting new HTTPS connection (1): pypi.org:443 DEBUG: https://pypi.org:443 "GET /pypi/Requests/json HTTP/1.1" 301 173 DEBUG: https://pypi.org:443 "GET /pypi/requests/json HTTP/1.1" 200 31330 DEBUG: Writing 2 requirements: ~equests, Requests to - ~equests Requests INFO: Successfully output requirements

alan-barzilay commented 3 years ago

Thank you for your reply! That's a really weird bug, and you don't seem to be the only one with it, issue #206 seems pretty similar. But for some reason I can't reproduce it in my machine using python 3.9. I wonder if this is something windows related and that's why I cant reproduce it. Do you have anything special in your setup besides using windows?

Mr-Zhen commented 3 years ago

I am using python 3.8.1 under miniconda on Windows system. And this problem still exists after I update python to 3.9.2. Then I try pure python 3.8, pure python 3.9 and python 3.8.1 under miniconda(similar with my host) on another Windows machine. But never reproduce it. Maybe there are some conflicts between the packages I have installed?

alan-barzilay commented 3 years ago

Are you using the same version of pipreqs on both of your machines?

Maybe there are some conflicts between the packages I have installed?

Perhaps, please let me know if you find how to reproduce it :)

Mr-Zhen commented 3 years ago

# the py file import requests import tqdm import certifi

DEBUG: Found packages: {'certifi', 'requests', 'tqdm'} DEBUG: Found imports: certifi, Requests, tqdm DEBUG: Getting packages information from Local/PyPI DEBUG: Starting new HTTPS connection (1): pypi.python.org:443 DEBUG: https://pypi.python.org:443 "GET /pypi/certifi/json HTTP/1.1" 301 122 DEBUG: Starting new HTTPS connection (1): pypi.org:443 DEBUG: https://pypi.org:443 "GET /pypi/certifi/json HTTP/1.1" 200 12842 DEBUG: Starting new HTTPS connection (1): pypi.python.org:443 DEBUG: https://pypi.python.org:443 "GET /pypi/Requests/json HTTP/1.1" 301 122 DEBUG: Starting new HTTPS connection (1): pypi.org:443 DEBUG: https://pypi.org:443 "GET /pypi/Requests/json HTTP/1.1" 301 173 DEBUG: https://pypi.org:443 "GET /pypi/requests/json HTTP/1.1" 200 31330 DEBUG: Starting new HTTPS connection (1): pypi.python.org:443 DEBUG: https://pypi.python.org:443 "GET /pypi/tqdm/json HTTP/1.1" 301 122 DEBUG: Starting new HTTPS connection (1): pypi.org:443 DEBUG: https://pypi.org:443 "GET /pypi/tqdm/json HTTP/1.1" 200 57637 DEBUG: Writing 6 requirements: ~qdm, ~equests, ~ertifi, certifi, Requests, tqdm to - ~qdm==4.42.1 ~equests==2.24.0 ~ertifi==2019.11.28 certifi==2020.12.5 Requests==2.25.1 tqdm==4.60.0 INFO: Successfully output requirements

image

I find these packages begain with "~" in the site-packages directory cause this problem. It performs normal after I delete these packages.

alan-barzilay commented 3 years ago

That is weird but I'm glad the issue is fixed. Not sure if there is something we can change in pipreqs to avoid this sort of problem since it seems to be something external. My guess is that this is miniconda's fault. I will close this issue since your main problem seems to be solved, but feel free to reopen it if I'm mistaken. Also, if you learn anything else about what caused this problem, please let me know :)