LoginSignup
3
0

pipreqsを使用してrequirements.txtを自動生成する

Last updated at Posted at 2024-03-13

pythonで個人開発でローカルでいろいろ作ってたので依存管理自動でできないかなと思ったらちゃんとpipreqsっていう自動生成できるってのがあったので使ってみる。
pipreqsの中身はこちら
https://github.com/bndr/pipreqs

pipreqsをインストール
pip install pipreqs
requirements.txtを以下のコマンドで作成
pipreqs .(ディレクトリ内で実行)
image.png
更新すると自動作成されます。

追記
INFO: Not scanning for jupyter notebooks. WARNING: Import named "azure_storage" not found locally. Trying to resolve it at the PyPI server. WARNING: Import named "azure_storage" was resolved to "azure-storage:0.37.0" package (https://pypi.org/project/azure-storage/). Please, verify manually the final list of requirements.txt to avoid possible dependency confusions. WARNING: Import named "python-dotenv" not found locally. Trying to resolve it at the PyPI server. WARNING: Import named "python-dotenv" was resolved to "python-dotenv:1.0.1" package (https://pypi.org/project/python-dotenv/). Please, verify manually the final list of requirements.txt to avoid possible dependency confusions. INFO: Successfully saved requirements file in .\requirements.txt
image.png
ん?なんかいらないものあるし、なんか少ないので見てみると警告が出ていた。
要約するとpipreqsが自動でパッケージ名を推測したものの、その推測に完全ではないから確認してねと言っている。
azure_storageってのがあるらしいので入れたから確認してねと言っている。
実際はazure-search-documentsなのに、比較的新しいライブラリだから知らないんだろうか。
結局手動で確認して正しいのはこっちでした。完全自動は無理なようでした。

openai==0.27.0
pandas==1.5.1
python-dotenv==1.0.1
streamlit==1.24.0
azure-core==1.29.4
azure-search-documents==11.4.0
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0