我有一个虚拟环境,安装了elasticsearch
Python包。
我想找出哪个包依赖于elasticsearch
并在虚拟环境中进行了安装。
(.venv)root@test:~# pip freeze | grep elast
elasticsearch==1.4.0.dev0
我尝试了一些来自使用pip显示反向依赖关系的解决方案,但它并没有起作用。
(.venv)root@test:~# python
Python 2.7.8 (default, Oct 18 2014, 12:50:18)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip
>>> package_name = 'elasticsearch'
>>> rev_dep = [pkg.project_name for pkg in pip.get_installed_distributions() if package_name in [requirement.project_name for requirement in pkg.requires()]]
>>> rev_dep
[]
>>>
模块路径返回虚拟环境路径。
(.venv)root@test:~# python -c 'import elasticsearch; print elasticsearch.__path__'
['/opt/venvs/.venv/local/lib/python2.7/site-packages/elasticsearch']
我有疑问,elasticsearch
Debian包是否安装了这个Python包,但不确定。
(.venv)root@test:~# dpkg -l | grep elast
ii elasticsearch 1.2.0 all Open Source, Distributed, RESTful Search Engine
elasticsearch
安装的位置(以便您知道是否正在使用系统包)。请提供以下命令的输出:python -c 'import elasticsearch; print elasticsearch.__path__'
。 - Thomas Orozco