Jmi*_*lls 86
已接受的答案不再适用于更新的pip版本,并且在不仔细阅读多条评论的情况下不会给出即时答案,因此我提供了更新的答案.
这与PIP测试版本8.1.2,9.0.1,10.0.1和18.1.
要在Linux上使用,而不会使当前目录混乱
pip download [package] -d /tmp --no-binary :all:
Run Code Online (Sandbox Code Playgroud)
-d
告诉pip下载应放入文件的目录.
更好的是,只需使用此脚本作为包名称参数,仅将依赖项作为输出:
#!/bin/sh
PACKAGE=$1
pip download $PACKAGE -d /tmp --no-binary :all: \
| grep Collecting \
| cut -d' ' -f2 \
| grep -Ev "$PACKAGE(~|=|\!|>|<|$)"
Run Code Online (Sandbox Code Playgroud)
也可以在这里.
wim*_*wim 35
看看johnnydep!
安装:
pip install johnnydep
Run Code Online (Sandbox Code Playgroud)
用法示例:
$ johnnydep requests
name summary
------------------------- ----------------------------------------------------------------------
requests Python HTTP for Humans.
??? certifi>=2017.4.17 Python package for providing Mozilla's CA Bundle.
??? chardet<3.1.0,>=3.0.2 Universal encoding detector for Python 2 and 3
??? idna<2.7,>=2.5 Internationalized Domain Names in Applications (IDNA)
??? urllib3<1.23,>=1.21.1 HTTP library with thread-safe connection pooling, file post, and more.
Run Code Online (Sandbox Code Playgroud)
一棵更复杂的树:
$ johnnydep ipython
name summary
-------------------------------- -----------------------------------------------------------------------------
ipython IPython: Productive Interactive Computing
??? appnope Disable App Nap on OS X 10.9
??? decorator Better living through Python with decorators
??? jedi>=0.10 An autocompletion tool for Python that can be used for text editors.
? ??? parso==0.1.1 A Python Parser
??? pexpect Pexpect allows easy control of interactive console applications.
? ??? ptyprocess>=0.5 Run a subprocess in a pseudo terminal
??? pickleshare Tiny 'shelve'-like database with concurrency support
??? prompt-toolkit<2.0.0,>=1.0.4 Library for building powerful interactive command lines in Python
? ??? six>=1.9.0 Python 2 and 3 compatibility utilities
? ??? wcwidth Measures number of Terminal column cells of wide-character codes
??? pygments Pygments is a syntax highlighting package written in Python.
??? setuptools>=18.5 Easily download, build, install, upgrade, and uninstall Python packages
??? simplegeneric>0.8 Simple generic functions (similar to Python's own len(), pickle.dump(), etc.)
??? traitlets>=4.2 Traitlets Python config system
??? decorator Better living through Python with decorators
??? ipython-genutils Vestigial utilities from IPython
??? six Python 2 and 3 compatibility utilities
Run Code Online (Sandbox Code Playgroud)
Tra*_*ger 16
你可以直接用pip得到的最接近的是使用pip
参数:
pip install --no-install <package>
Run Code Online (Sandbox Code Playgroud)
例如,这是安装芹菜时的输出:
Downloading/unpacking celery
Downloading celery-2.5.5.tar.gz (945Kb): 945Kb downloaded
Running setup.py egg_info for package celery
no previously-included directories found matching 'tests/*.pyc'
no previously-included directories found matching 'docs/*.pyc'
no previously-included directories found matching 'contrib/*.pyc'
no previously-included directories found matching 'celery/*.pyc'
no previously-included directories found matching 'examples/*.pyc'
no previously-included directories found matching 'bin/*.pyc'
no previously-included directories found matching 'docs/.build'
no previously-included directories found matching 'docs/graffles'
no previously-included directories found matching '.tox/*'
Downloading/unpacking anyjson>=0.3.1 (from celery)
Downloading anyjson-0.3.3.tar.gz
Running setup.py egg_info for package anyjson
Downloading/unpacking kombu>=2.1.8,<2.2.0 (from celery)
Downloading kombu-2.1.8.tar.gz (273Kb): 273Kb downloaded
Running setup.py egg_info for package kombu
Downloading/unpacking python-dateutil>=1.5,<2.0 (from celery)
Downloading python-dateutil-1.5.tar.gz (233Kb): 233Kb downloaded
Running setup.py egg_info for package python-dateutil
Downloading/unpacking amqplib>=1.0 (from kombu>=2.1.8,<2.2.0->celery)
Downloading amqplib-1.0.2.tgz (58Kb): 58Kb downloaded
Running setup.py egg_info for package amqplib
Successfully downloaded celery anyjson kombu python-dateutil amqplib
Run Code Online (Sandbox Code Playgroud)
不可否认,这确实会以临时文件的形式留下一些残余,但它确实实现了目标.如果你使用virtualenv(你应该这样做)这样做,清理就像删除--no-install
目录一样简单.
pgm*_*ank 13
PyPi 提供带有包元数据的 JSON 端点:
Run Code Online (Sandbox Code Playgroud)>>> import requests >>> url = 'https://pypi.org/pypi/{}/json' >>> json = requests.get(url.format('pandas')).json() >>> json['info']['requires_dist'] ['numpy (>=1.9.0)', 'pytz (>=2011k)', 'python-dateutil (>=2.5.0)'] >>> json['info']['requires_python'] '>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*'
对于特定的软件包版本,请在 URL 中添加额外的版本段:
Run Code Online (Sandbox Code Playgroud)https://pypi.org/pypi/pandas/0.22.0/json
另外,如果您使用 conda (按照 @ShpielMeister 的建议),您可以使用:
conda info package==X.X.X
Run Code Online (Sandbox Code Playgroud)
显示信息,包括特定版本的依赖项或:
conda info package
Run Code Online (Sandbox Code Playgroud)
显示信息,包括有关该包的所有受支持版本的依赖项。
Sar*_*ica 12
当且仅当包安装时,您可以使用pip show <package>
.Requires:
在输出结尾处查找字段.显然,这会破坏您的要求,但仍然有用.
例如:
$ pip --version
pip 7.1.0 [...]
$ pip show pytest
---
Metadata-Version: 2.0
Name: pytest
Version: 2.7.2
Summary: pytest: simple powerful testing with Python
Home-page: http://pytest.org
Author: Holger Krekel, Benjamin Peterson, Ronny Pfannschmidt, Floris Bruynooghe and others
Author-email: holger at merlinux.eu
License: MIT license
Location: /home/usr/.tox/develop/lib/python2.7/site-packages
Requires: py
Run Code Online (Sandbox Code Playgroud)
使用pipdeptree ( pip install pipdeptree
)。需要安装该包。
$ pipdeptree -p pandas\npandas==1.2.2\n - numpy [required: >=1.16.5, installed: 1.19.5]\n - python-dateutil [required: >=2.7.3, installed: 2.8.1]\n - six [required: >=1.5, installed: 1.15.0]\n - pytz [required: >=2017.3, installed: 2021.1]\n
Run Code Online (Sandbox Code Playgroud)\n使用johnnydep ( pip install johnnydep
)。速度较慢,因为它下载了软件包的轮子。
$ johnnydep pandas\n2021-06-09 11:01:21 [info ] init johnnydist [johnnydep.lib] dist=pandas parent=None\n2021-06-09 11:01:22 [info ] init johnnydist [johnnydep.lib] dist=numpy>=1.16.5 parent=pandas\n2021-06-09 11:01:22 [info ] init johnnydist [johnnydep.lib] dist=python-dateutil>=2.7.3 parent=pandas\n2021-06-09 11:01:23 [info ] init johnnydist [johnnydep.lib] dist=pytz>=2017.3 parent=pandas\n2021-06-09 11:01:23 [info ] init johnnydist [johnnydep.lib] dist=six>=1.5 parent=python-dateutil>=2.7.3\nname summary\n-------------------------- -----------------------------------------------------------------------\npandas Powerful data structures for data analysis, time series, and statistics\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 numpy>=1.16.5 NumPy is the fundamental package for array computing with Python.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 python-dateutil>=2.7.3 Extensions to the standard Python datetime module\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 six>=1.5 Python 2 and 3 compatibility utilities\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 pytz>=2017.3 World timezone definitions, modern and historical\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
48210 次 |
最近记录: |