pip在哪里安装带有虚拟环境的软件包? [英] Where does pip install packages with a virtual environment?
问题描述
情况:我已经创建了一个虚拟环境,并使用显式路径来运行pip
(无需采购activate
).它是将软件包安装在全局dist-packages
中还是将它们安装在虚拟环境的site-packages
中.
Situation: I have created a virtual environment and use an explicit path to run pip
(without sourcing activate
). Does it install packages in the global dist-packages
or does it install them in the virtual environment's site-packages
.
详细信息:
正如 pip在何处安装其软件包?所述,pip在pip
可执行文件.这是否仍将软件包安装在virtualenv的站点软件包中?还是将它们安装在/local/lib/<python-version>/dist-packages
中?
Details:
As Where does pip install its packages? explains, pip installs packages in <virtualenv_name>/lib/<python_ver>/site-packages
when used with a virtual environment. From my experience, this is true when I activate the virtualenv. I have an existing bash script that paths directly to the pip
executable without activating the virtualenv. Does this still install packages in the virtualenv's site-packages? Or does it install them in /local/lib/<python-version>/dist-packages
?
注意:我正在使用Ubuntu 16.04
Note: I'm on Ubuntu 16.04
推荐答案
这很大程度上取决于哪个版本(不是语义版本,而是……的具有多个版本")创建venv时安装的pip)脚本正在使用的pip及其配置(可能包括您的环境).
This very much depends on which version (not in the semantic version sense, but of the having-multiple-"versions" of pip installed when you create a venv) of pip your script is using, as well as its configuration (including possibly your environment).
假设您的脚本中有一行
/some/path/to/pip install <some package>
,并假设该pip已安装至少一个软件包,则可以使用
and assuming that that pip has installed at least one package, you can use
/some/path/to/pip show <that package>
,它将为您提供如下输出:
and it'll give you output that looks like:
$ pip show numpy
Name: numpy
Version: 1.14.5
Summary: NumPy: array processing for numbers, strings, records, and objects.
Home-page: http://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /usr/lib/python3/dist-packages
Requires:
倒数第二个位置线应有助于回答您的问题.
The location line second to last should help answering your question.
这篇关于pip在哪里安装带有虚拟环境的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!