やりたいこと
pip install
したライブラリ群をそのままGitにpushしたため、requirements.txt
にライブラリ群を集約したい- そのため、
pip install
したライブラリ群のバージョンを確認したい
- そのため、
【結論】ライブラリのバージョンを確認する
pip freeze
または、pip list
で確認する
pip freeze
reqirements.txt
の記述形式で出力してくれる。
$ pip freeze blinker==1.3 boto3==1.7.31 botocore==1.10.31 chardet==2.3.0 cloud-init==18.2 command-not-found==0.3 configobj==5.0.6 cryptography==1.2.3 docutils==0.14 ・・・略・・・
pip list
見やすいのはこちら。
$ pip list Package Version ------------------- ---------------------- blinker 1.3 boto3 1.7.31 botocore 1.10.31 chardet 2.3.0 cloud-init 18.2 command-not-found 0.3 configobj 5.0.6 cryptography 1.2.3 docutils 0.14 ・・・略・・・
特定のライブラリをgrep
したりもできる。
$ pip list | grep json jsonpatch 1.10 jsonpointer 1.9
JSON形式で出力も可能。
$ pip list --format=json | grep json [{"name": "blinker", "version": "1.3"}, {"name": "boto3", "version": "1.7.31"}, {"name": "botocore", "version": "1.10.31"}, {"name": "chardet", "version": "2.3.0"}, {"name": "cloud-init", "version": "18.2"}, {"name": "command-not-found", "version": "0.3"}, {"name": "configobj", "version": "5.0.6"}, {"name": "cryptography", "version": "1.2.3"}, {"name": "docutils", "version": "0.14"}, {"name": "idna", "version": "2.0"}, {"name": "Jinja2", "version": "2.8"}, {"name": "jmespath", "version": "0.9.3"}, {"name": "jsonpatch", "version": "1.10"}, {"name": "jsonpointer", "version": "1.9"}, {"name": "language-selector", "version": "0.1"}, {"name": "MarkupSafe", "version": "0.23"}, {"name": "oauthlib", "version": "1.0.3"}, {"name": "pip", "version": "10.0.1"}, {"name": "prettytable", "version": "0.7.2"}, {"name": "psycopg2", "version": "2.7.4"}, {"name": "pyasn1", "version": "0.1.9"}, {"name": "pycurl", "version": "7.43.0"}, {"name": "pygobject", "version": "3.20.0"}, {"name": "PyJWT", "version": "1.3.0"}, {"name": "pyserial", "version": "3.0.1"}, {"name": "python-apt", "version": "1.1.0b1+ubuntu0.16.4.1"}, {"name": "python-dateutil", "version": "2.7.3"}, {"name": "python-debian", "version": "0.1.27"}, {"name": "python-lambda-local", "version": "0.1.5"}, {"name": "python-systemd", "version": "231"}, {"name": "PyYAML", "version": "3.11"}, {"name": "requests", "version": "2.9.1"}, {"name": "s3transfer", "version": "0.1.13"}, {"name": "setuptools", "version": "39.0.1"}, {"name": "six", "version": "1.10.0"}, {"name": "ssh-import-id", "version": "5.5"}, {"name": "ufw", "version": "0.35"}, {"name": "unattended-upgrades", "version": "0.1"}, {"name": "urllib3", "version": "1.13.1"}, {"name": "wheel", "version": "0.31.0"}]