[英]What's the difference between apt-get virtualenv and pip virtualenv?
What's the difference between the virtualenv from apt-get and that from pip? apt-get 的 virtualenv 和 pip 的 virtualenv 有什么区别? Are they interchangeable?
它们可以互换吗?
apt-get install virtualenv
The following extra packages will be installed:
python-chardet-whl python-colorama-whl python-distlib-whl python-html5lib-whl python-pip-whl python-requests-whl
python-setuptools-whl python-six-whl python-urllib3-whl python3-virtualenv
The following NEW packages will be installed:
python-chardet-whl python-colorama-whl python-distlib-whl python-html5lib-whl python-pip-whl python-requests-whl
python-setuptools-whl python-six-whl python-urllib3-whl python3-virtualenv virtualenv
At a high-level apt
is something maintained by your system.在高级别的
apt
是由您的系统维护的东西。 Specifically anything in the debian family will use apt
to manage things like drivers, compilers, things that require lower-level integration.特别是 debian 系列中的任何东西都将使用
apt
来管理诸如驱动程序、编译器、需要较低级别集成的东西。
This means for things like numpy
and scipy
that require system-level integration with FORTRAN libraries, including the pip
dependency won't actually work.这意味着对于需要与 FORTRAN 库进行系统级集成的
numpy
和scipy
类的东西,包括pip
依赖项实际上将不起作用。
Some python packages that are tightly-linked with the system-level dependencies maintain apt
packages that simply give you the full package all at once without having to coordinate between the two.一些与系统级依赖关系紧密相关的 python 包维护着
apt
包,这些包可以一次性为您提供完整的包,而无需在两者之间进行协调。 The minus is that because Canonical's review process is pretty meticulous (as it should be) you will be getting, 9/10 a less-recent version of the library you're trying to use.缺点是因为 Canonical 的审查过程非常细致(应该如此),您将获得 9/10 的较新版本的库,您正在尝试使用。
So, in short: you will often require apt
packages to enable more recent pip
installs, and while the same python dependencies may be available via apt
, these libraries are typically much older and may not have required functionality.因此,简而言之:您通常需要
apt
包来启用更新的pip
安装,虽然相同的 python 依赖项可以通过apt
,但这些库通常更旧,可能没有所需的功能。
A common workaround is to simply use the system dependencies from one of these packages rather than the full package.一种常见的解决方法是简单地使用这些包中的一个而不是完整包中的系统依赖项。 You can do this by use the
build-deps
flag.您可以通过使用
build-deps
标志来做到这一点。 A common example given below:下面给出一个常见的例子:
apt-get build-dep python-scipy
pip install scipy
Which will actually give you the most up-to-date version of scipy while working within your virtualenv.在您的 virtualenv 中工作时,这实际上会为您提供最新版本的 scipy。
apt
or apt-get
- installer debian similar distributions and install the packages in the directory /usr/lib/python2.7/dist-packages
. apt
或apt-get
- 安装 debian 类似发行版,并将软件包安装在目录/usr/lib/python2.7/dist-packages
。
pip install
- python package manager and install the packages in the directory /usr/local/lib/python2.7/dist-packages
pip install
- python 包管理器并将包安装在目录/usr/local/lib/python2.7/dist-packages
Both directories are in the path of python that it is looking for modules import.这两个目录都在它正在寻找模块导入的python的路径中。
>>> import sys
>>> sys.path
['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']
They use separate repositories, you can check what versions you're getting from pip
through here .他们使用单独的存储库,您可以通过此处检查从
pip
获得的版本。 As for apt-get
you'll have to check your operating system's package manager version and source list to see what versions you're getting from there.至于
apt-get
您必须检查操作系统的包管理器版本和源列表,以查看从那里获得的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.