--use-local creates empty requirements.txt
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 424
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I would like to use --use-local flag to create my requirements.txt. But unfortunately it creates an empty file (Writing 0 requirements). But --debug tells me that it has found 3 libs (Found imports: pyserial, PySimpleGUI, PyYAML).
If I use pipreqs without --use-local I get a requirements file with the 3 entries.
pipreqs version is 0.4.10
Python version is 3.8.5
**with --use-local requirements.txt is empty (Writing 0 requirements)**
```
✔ $ python3 -m pipreqs.pipreqs --force --debug --use-local ./
DEBUG: Found packages: {'sys', 're', 'collections', 'datetime', 'PySimpleGUI', 'io', 'itertools', 'random', 'yaml', 'serial', 'time', 'os'}
DEBUG: Found imports: pyserial, PySimpleGUI, PyYAML
DEBUG: Getting package information ONLY from local installation.
DEBUG: Writing 0 requirements: to ./requirements.txt
INFO: Successfully saved requirements file in ./requirements.txt
```
**without --use-local it works (Writing 3 requirements)**
```
✔ $ python3 -m pipreqs.pipreqs --force --debug ./
DEBUG: Found packages: {'random', 'yaml', 'serial', 'time', 'datetime', 're', 'sys', 'PySimpleGUI', 'collections', 'io', 'os', 'itertools'}
DEBUG: Found imports: pyserial, PySimpleGUI, PyYAML
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/pyserial/json HTTP/1.1" 301 122
DEBUG: Starting new HTTPS connection (1): pypi.org:443
DEBUG: https://pypi.org:443 "GET /pypi/pyserial/json HTTP/1.1" 200 5576
DEBUG: Starting new HTTPS connection (1): pypi.python.org:443
DEBUG: https://pypi.python.org:443 "GET /pypi/PySimpleGUI/json HTTP/1.1" 301 122
DEBUG: Starting new HTTPS connection (1): pypi.org:443
DEBUG: https://pypi.org:443 "GET /pypi/PySimpleGUI/json HTTP/1.1" 200 27843
DEBUG: Starting new HTTPS connection (1): pypi.python.org:443
DEBUG: https://pypi.python.org:443 "GET /pypi/PyYAML/json HTTP/1.1" 301 122
DEBUG: Starting new HTTPS connection (1): pypi.org:443
DEBUG: https://pypi.org:443 "GET /pypi/PyYAML/json HTTP/1.1" 200 43612
DEBUG: Writing 3 requirements: pyserial, PySimpleGUI, PyYAML to ./requirements.txt
INFO: Successfully saved requirements file in ./requirements.txt
✔ $ cat requirements.txt
pyserial==3.5
PySimpleGUI==4.38.0
PyYAML==5.4.1
```
Contributor guide
Research direction
Start by tracing the --use-local package-information path and compare it with the normal Local/PyPI lookup shown in the debug output. Reproduce the issue with the provided pipreqs command and imports, then ensure local lookup writes the discovered pyserial, PySimpleGUI, and PyYAML entries to requirements.txt.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100