pipreqs not capturing all imports
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 424
- PR merge metrics
- No merged PRs in 30d
Description
In my code I wanted to create a requirements.txt file with all the dependencies needed to run my model.
I used pip freeze earlier, however, because of obvious reasons i.e. it captures everything from the environment and not just the ones needed for my model, I moved to pipreqs.
I tested it with a very basic .py file with some imports, out of those the following is not getting captured correctly:
`import cv2`
The problem I faces is:
It fails to capture opencv-python for cv2.
Below error is thrown:
DEBUG: Starting new HTTPS connection (1): pypi.org
DEBUG: https://pypi.org:443 "GET /cv2/json HTTP/1.1" 404 1443
DEBUG: Package cv2 does not exist or network problems
Can anyone help here.
Contributor guide
Research direction
Start by reproducing the issue with a basic .py file containing `import cv2`, then inspect how pipreqs resolves imports before its PyPI lookup. The work is done when the generated requirements.txt includes `opencv-python` for that import and the cv2 lookup error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- opencv, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100