简体   繁体   English

pip 和 conda 在哪里保存已安装软件包的列表,以便他们知道谁安装了什么?

[英]Where does pip and conda keep the list of installed packages so that they know who installed what?

I did some pip install in my conda environment, and it seems that both conda and pip follow the python convention, by installing packages into the site-packages folder.我在我的conda环境中做了一些pip install ,似乎condapip遵循 python 约定,通过将包安装到site-packages文件夹中。

When I use pip list and conda list , it seems they did a nice book keeping of who installed which packages.当我使用pip listconda list ,他们似乎很好地记录了谁安装了哪些软件包。 Question is, where are those two installation lists stored, on Linux?问题是,这两个安装列表在 Linux 上存储在哪里?

In case of pip list , the pkg_resources library is used to access resource files for Python Libraries.pip list情况下, pkg_resources库用于访问 Python 库的资源文件。

For this, a Working Set access the active distributions.为此, 工作集访问活动分布。 From the docs, a working set从文档中,一个工作集

represents the distributions that are currently active on sys.path.表示当前在 sys.path 上处于活动状态的发行版。

Thus, when calling an instance of WorkingSet , by default it will search for modules located on sys.path .因此,当调用WorkingSet的实例时,默认情况下它将搜索位于sys.path上的模块。

For example, when I run sys.path例如,当我运行sys.path

['/opt/conda/lib/python37.zip',
 '/opt/conda/lib/python3.7',
 '/opt/conda/lib/python3.7/lib-dynload',
 '',
 '/opt/conda/lib/python3.7/site-packages',
 '/opt/conda/lib/python3.7/site-packages/IPython/extensions'
]

These are the paths that will be used to search for installed packages.这些是将用于搜索已安装包的路径。 An example follows一个例子如下

import pkg_resources

# Define working set
working_set = pkg_resources.working_set

# Package, version and location 
[d for d in working_set]
>>>
[zipp 3.1.0 (/opt/conda/lib/python3.7/site-packages),
 zict 2.0.0 (/opt/conda/lib/python3.7/site-packages),
...,
attrs 19.3.0 (/opt/conda/lib/python3.7/site-packages),
 async-generator 1.10 (/opt/conda/lib/python3.7/site-packages),
 alembic 1.4.2 (/opt/conda/lib/python3.7/site-packages)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Conda:软件包已通过pip安装,但未在conda列表中显示 - Conda: packages are already installed by pip but not shown in conda list 如何知道使用pip安装了哪些软件包 - How to know what packages are installed with pip conda 是否从使用 pip install 安装的 pypi 更新包? - Does conda update packages from pypi installed using pip install? conda列表未显示使用pip安装的软件包 - Installed packages using pip don't seen by conda list Python包用与pip和conda一起安装的重复项 - Python packages duplicates installed with pip and conda 如何在Anaconda(Conda)环境中跟踪pip安装的软件包? - How do I keep track of pip-installed packages in an Anaconda (Conda) environment? pip 没有找到conda已经安装的cudatoolkit - pip does not find the cudatoolkit that conda has installed 如果我使用 pip 安装 Anaconda 中未包含的软件包,package 是否也会安装在 conda 环境中? - Does a package also gets installed in conda environment if I use pip to install packages not included in Anaconda? pip 如何解析 install_requires 中的条目,尤其是关于已经从 conda 安装的软件包? - How does pip resolve entries in install_requires especially in regards to already installed packages from conda? conda 无法识别已安装的软件包 - Installed packages not recognized by conda
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM