Bre*_*bel 19 python pip python-packaging
有没有办法获得给定python包的依赖项列表而不先安装它?
我目前可以获得要求列表,但它需要安装包.例如,我可以使用pip来显示基本需求信息,但它不包含版本信息:
$ pip show pytest
Name: pytest
Version: 3.0.6
...
Requires: colorama, setuptools, py
Run Code Online (Sandbox Code Playgroud)
我已经尝试过一个名为pipdeptree
包含更好输出要求的库,但它也需要安装包
$ pipdeptree -p pytest
pytest==3.0.6
- colorama [required: Any, installed: 0.3.7]
- py [required: >=1.4.29, installed: 1.4.32]
- setuptools [required: Any, installed: 34.0.0]
- appdirs [required: >=1.4.0, installed: 1.4.0]
...
Run Code Online (Sandbox Code Playgroud)
理想情况下,我会得到pipdeptree
提供的详细程度.此外,能够requirements.txt
从python wheel
或pypi 生成文件pip
也足够了.
编辑:
我看过类似的问题.它们要么过时,需要安装,要么它们不列出给定包的单个依赖项,只列出解决依赖性要求后最终下载的包的列表.例如,我并不关心pip下载package-2.3.4
,我宁愿知道这package>=2.1
是一个要求.
小智 9
PyPi为包含元数据的JSON端点提供:
>>> 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.*'
Run Code Online (Sandbox Code Playgroud)
对于特定包版本,请在URL中添加其他版本段:
https://pypi.org/pypi/pandas/0.22.0/json
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3886 次 |
最近记录: |