Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

python - 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? 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

At a high-level apt is something maintained by your system. Specifically anything in the debian family will use apt to manage things like drivers, compilers, things that require lower-level integration.

This means for things like numpy and scipy that require system-level integration with FORTRAN libraries, including the pip dependency won't actually work.

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. 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.

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.

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. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...