Pipreqs missing optional dependency package requirement
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 424
- PR merge metrics
- No merged PRs in 30d
Description
Most of the time, I use `pipreqs` to generate a `requirements.txt` file so anyone can reproduce the working environment on their side based on that requirements file.
Here I am facing a case where there is a missing package requirement in the file generated by pipreqs, so the code is not running out of the box in a freshly created environment using the `requirements.txt` file.
```bash
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
```
The missing package is `openpyxl` which is an optional dependency of `pandas`.
```bash
>>> import pandas as pd
>>> pd.show_versions()
INSTALLED VERSIONS
------------------
commit : 5f648bf1706dd75a9ca0d29f26eadfbb595fe52b
python : 3.9.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19042
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : English_Canada.1252
pandas : 1.3.2
numpy : 1.21.4
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 59.6.0
Cython : None
... ...
openpyxl : None <== HERE!
... ...
numba : None
```
Indeed, the content of the generated `requirements.txt` file does not contain `openpyxl`, but contains `pandas`:
```bash
pandas==1.3.2
plotly==5.4.0
```
Is there a way that `pipreqs` could outputs the `pandas` dependencies in the generated `requirements.txt` file so I don't have to enter it manually?
*_Originally posted on stack overflow => _
Contributor guide
Research direction
Reproduce the report by running pipreqs on a project that imports pandas and requires openpyxl, then inspect how imported packages and their metadata become requirements. Done means the generated requirements file includes the requested optional dependency while retaining the direct pandas requirement, with coverage added for this behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100