What is the difference between installing a package using pip vs. apt-get?

20,911

Solution 1

You probably already know the benefits of apt-get. Automatic update notifications, other apt-installed packages that need those tools know they're installed, etc.

With pip, you know you're getting the latest version at the time you install it, you can install to a non-default version of Python, and you can install to a virtualenv.

If you don't need any of the features pip gives you, and you don't routinely have to install other Python packages which aren't available over APT, use the APT versions.

Solution 2

Most answers to this question miss one of the advantages using apt-get:

apt-get is pre-compiled, which installs much faster than pip.

To install numpy, matplotlib, pandas, and other scipy-related modules, apt-get only takes seconds; pip can easily consume 10min+.

If you have root access and don't mind a little outdated versions, apt-get is the fast & worry-free way to go.

Solution 3

You should be aware that what makes it in the package manager undergoes some integration testing, while what is in Pypi is untested.

Pypi is OK for development.

In production, you may go with Pypi, but you will soon learn that you can always rely on what is in the package manager...

Solution 4

I always recommend installing Python package with pip, because some OS package managers do packages customizations, and it can either break or change package's behavior.

If you need to install a package globally:

$ sudo pip install PACKAGE

And it will try to download your package from PyPI or project's links.

Solution 5

Which one should you use: Both apt-get and pip are mature package managers which automatically install any other package dependency while installing. You may use anyone as you like. However, if you need to install a particular version of python-package, or install the package in a virtualenv, or install a package which is only hosted on PyPI; only pip would help you solve that issue. Otherwise, if you don't mind installing the packages in system-wide location it doesn't really matter whether you use apt-get or pip.

Share:
20,911
Mridang Agarwalla
Author by

Mridang Agarwalla

I'm a software developer who relishes authoring Java and Python, hacking on Android and toying with AppEngine. I have a penchant for development and a passion for the business side of software. In between all the work, I contribute to a number of open-source projects, learn to master the art of cooking Asian cuisine and try to stay sane while learning to fly my Align Trex-600 Nitro Heli.

Updated on November 10, 2021

Comments

  • Mridang Agarwalla
    Mridang Agarwalla over 2 years

    I'm trying to deploy a Django site on an Ubuntu machine. I need to install Psycopg2 and PIL but it seems that I'm able to install them using either apt-get or using pip. Is there a difference in installing by the two methods? I know that using pip, I'm able to install it into a virtual environment but with apt-get it installs in the global python environment.

  • gnebehay
    gnebehay over 7 years
    Since the arrival of wheel, pip also provides binary packages.
  • laviex
    laviex over 7 years
    It seemed not all packages had wheels available, at least for the system I was on. Especially math packages such as numpy, pandas, matplotlib etc.
  • jrh
    jrh over 5 years
    "With pip, you know you're getting the latest version at the time you install it", this could be a crucial point, and I'd like to emphasize something, when you install through apt you're usually restricted to the version of the version(s) of the package your distro supports.