使用pip,是否可以確定當前安裝了哪個版本的軟件包?找到與pip一起安裝的軟件包版本
我知道pip install XYZ --upgrade
但我想知道如果有喜歡的東西pip info XYZ
。如果不是,那麼告訴我目前使用哪個版本的最好方法是什麼。
使用pip,是否可以確定當前安裝了哪個版本的軟件包?找到與pip一起安裝的軟件包版本
我知道pip install XYZ --upgrade
但我想知道如果有喜歡的東西pip info XYZ
。如果不是,那麼告訴我目前使用哪個版本的最好方法是什麼。
作爲pip 1.3,有一個pip show
命令。
$ pip show Jinja2
---
Name: Jinja2
Version: 2.7.3
Location: /path/to/virtualenv/lib/python2.7/site-packages
Requires: markupsafe
在舊版本中,pip freeze
和grep
應該做的工作很好。
$ pip freeze | grep Jinja2
Jinja2==2.7.3
'pip freeze'命令的名字很奇怪。 – 2014-01-14 08:49:23
@techtonik:它用於[凍結當前模塊](http://www.pip-installer.org/en/1.1/requirements.html)到requirements.txt。 – Hugo 2014-02-15 10:59:55
@Hugo:我會使用'save'名稱。 – 2014-02-17 16:31:30
您還可以安裝yolk
,然後運行yolk -l
這也給了一些很好的輸出。下面是我得到了我的小的virtualenv:
(venv)CWD> /space/vhosts/pyramid.xcode.com/venv/build/unittest
[email protected] 43> yolk -l
Chameleon - 2.8.2 - active
Jinja2 - 2.6 - active
Mako - 0.7.0 - active
MarkupSafe - 0.15 - active
PasteDeploy - 1.5.0 - active
Pygments - 1.5 - active
Python - 2.7.3 - active development (/usr/lib/python2.7/lib-dynload)
SQLAlchemy - 0.7.6 - active
WebOb - 1.2b3 - active
account - 0.0 - active development (/space/vhosts/pyramid.xcode.com/project/account)
distribute - 0.6.19 - active
egenix-mx-base - 3.2.3 - active
ipython - 0.12 - active
logilab-astng - 0.23.1 - active
logilab-common - 0.57.1 - active
nose - 1.1.2 - active
pbkdf2 - 1.3 - active
pip - 1.0.2 - active
pyScss - 1.1.3 - active
pycrypto - 2.5 - active
pylint - 0.25.1 - active
pyramid-debugtoolbar - 1.0.1 - active
pyramid-tm - 0.4 - active
pyramid - 1.3 - active
repoze.lru - 0.5 - active
simplejson - 2.5.0 - active
transaction - 1.2.0 - active
translationstring - 1.1 - active
venusian - 1.0a3 - active
waitress - 0.8.1 - active
wsgiref - 0.1.2 - active development (/usr/lib/python2.7)
yolk - 0.4.3 - active
zope.deprecation - 3.5.1 - active
zope.interface - 3.8.0 - active
zope.sqlalchemy - 0.7 - active
我剛剛給拉請求PIP與增強雨果·塔瓦雷斯說:
(specloud爲例)
$ pip show specloud
Package: specloud
Version: 0.4.4
Requires:
nose
figleaf
pinocchio
皮普1.3現在還有一個list命令:
$ pip list
argparse (1.2.1)
pip (1.5.1)
setuptools (2.1)
wsgiref (0.1.2)
並帶--outdated作爲額外的參數,你會得到包的當前和最新版本使用的是:
$ pip list --outdated
distribute (Current: 0.6.34 Latest: 0.7.3)
django-bootstrap3 (Current: 1.1.0 Latest: 4.3.0)
Django (Current: 1.5.4 Latest: 1.6.4)
Jinja2 (Current: 2.6 Latest: 2.8)
因此,與AdamKG的回答結合:
$ pip list --outdated | grep Jinja2
Jinja2 (Current: 2.6 Latest: 2.8)
檢查PIP工具太:https://github.com/nvie/pip-tools
一個有趣的選項。我寧願把它們全部列出來,然後讓我知道它們中的任何一個是否已經過時。 – ArtOfWarfare 2014-08-13 17:42:29
最簡單的方法是:
import jinja2
print jinja2.__version__
這隻適用於在源代碼中定義了'__version__'的包。許多軟件包沒有。 – spookylukey 2016-07-28 06:37:00
您可以使用grep命令查明。
pip show <package_name>|grep Version
例子:
pip show urllib3|grep Version
將顯示只有一個版本。
元數據的版本:2.0
版本:1.12
你可以得到的軟件包列表和它們的版本,例如:
pip list
輸出:
appdirs (1.4.3)
BeautifulSoup (3.2.
beautifulsoup4 (4.6
certifi (2017.4.17)
chardet (3.0.4)
cookies (2.2.1)
dj-database-url (0.
Django (1.10.4)
django-allauth (0.3
django-filter (1.0.
django-haystack (2.
django-oauth-toolki
django-recaptcha (1
djangorestframework
djangorestframework
funcsigs (1.0.2)
gunicorn (19.7.1)
idna (2.5)
Jinja2 (2.9.6)
Markdown (2.6.8)
MarkupSafe (1.0)
mock (2.0.0)
MySQL-python (1.2.5
numpy (1.13.1)
oauthlib (2.0.2)
packaging (16.8)
pandas (0.20.3)
pbr (3.1.1)
pep8 (1.7.0)
pip (9.0.1)
psycopg2 (2.7.1)
PyJWT (1.5.2)
pyparsing (2.2.0)
python-dateutil (2.
python-decouple (3.
python-openid (2.2.
pytz (2017.2)
requests (2.18.1)
requests-oauthlib (
responses (0.5.1)
setuptools (35.0.1)
six (1.10.0)
social-auth-app-dja
social-auth-core (1
urllib3 (1.21.1)
virtualenv (15.1.0)
wheel (0.29.0)
whitenoise (3.3.0)
在Windows上,你可以發出命令,例如:
pip show setuptools | findstr "Version"
輸出:
Version: 34.1.1
有一個建議的在pip:htt中顯示'show'命令ps://github.com/pypa/pip/issues/33 – 2012-04-20 12:53:03