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

Viewed 23064

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.

7 Answers

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.

I found something about this. My ubuntu has both python version 3.6 and 3.7. When apt install python3-xxx, xxx will be installed at /usr/lib/python3/dist-packages, but pip3 install xxx at /usr/local/lib/python3.7(my default python version)/dist-packages. And when change python to version 3.6, xxx installed by pip3 could not work, while installed by apt works fine.

Sometimes the names are different:

sudo apt install libopencv-dev python3-opencv

pip install opencv-python

But sometimes the same:

enter image description here

Related