
こんな悩みを解決できる記事を書きました!
僕は現役フリーランスエンジニア(歴9年)で、資格は13個保有しています。
「requirements.txtを自動で作成したい」とお考えではありませんか?
requirements.txtを手動で作成するのは面倒ですし、漏れがないか不安になりますよね。
「pipreqs」を使えば自動でrequirements.txtを作成できるので時短になりますよ。



今回はpipreqsについて詳しく解説しますね♪


本記事を読み終われば、pipreqsの使い方が理解できるのでrequirements.txtを手動で作成する必要がなくなりますよ。



具体的なコマンド付きで解説するので、ぜひ最後まで読んでくださいね♪
pipreqsとは


pipreqsとは、Pythonプロジェクトに必要な依存関係を特定し、requirements.txtに自動エクスポートするためのツールです。
Pythonプロジェクト内のimport文を自動解析してrequirements.txtを作成するので、手動でファイルを作成する必要がありません。



requirements.txtの作成ならpipreqsは手放せません♪
pipreqsでrequirements.txtを作成する手順
pipreqsでrequirements.txtを作成する手順を解説します。
$ pip install pipreqs
pipreqsをインストールします。
$ pipreqs .
上記コマンドを実行すれば、ルートディレクトリにrequirements.txtが作成されます。



漏れがあるかもしれないので、最終確認はしておきましょう。
まとめ
今回は、pipreqsについて解説しました。
以下が本記事のまとめになります。
- おすすめ本
Pythonの勉強なら「独習Python



最後までお読みいただき、ありがとうございました!
- クソおすすめ本



海外のエンジニアがどういった思考で働いているかが理解できます。
海外に行く気はないけど海外エンジニアの動向が気になる雑魚エンジニアにおすすめです(本当におすすめな本しか紹介しないのでご安心を)。