What is the difference between installing a package using pip vs. apt-get?
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.
Whats the difference between `pip install pyqt5` and `sudo apt-get install python3-pyqt5`? [here pyQt5 itself is more a placeholder than anything]
apt
installs binary .deb
packages from apt repositories into system. pip
installs binary wheels or source packages from pypi
into system or into virtual environment. Python developers publish packages into pypi
, you have opportunity to install from apt
only if linux distribution maintainers (for some reason) took trouble of packaging for apt
. apt
packages are likely more stable, pip
packages are likely more recent.
Difference between installing by pip and installing globally
These are 2 separate package managers, that sometimes don't play well with each other.
# linux system level as root
(sudo) apt-get install
# inside of an more isolated python folder structure, that does not interface with the system level packages
(venv) pip install
You may* be able to install with all of the build tools:
sudo apt-get install python-pip python-dev build-essential
pip install --upgrade pip
What is the difference between pip install and sudo pip install?
pip install
Will run pip install
as the current user
sudo pip install
Will run pip install
with the security privileges of another user, root
for example.
You normally need to use sudo
to install a package on a system.
You may want to read linux-101-introduction-to-sudo
Difference between pip's mysql-python and apt-get's python-mysqldb
pip should get you the newest version of mysql-python which is available for the version of python that you're using from the pip repository.
Apt will give you the mysql-python version that is deemed "stable" by the debian, or ubuntu repository managers.
The functionality (or security) of the packages could be different based on version differences.
The benefit of using pip install mysql-python, is that you can be using virtualenv and have the specific version installed for that package or framework.
What's the difference between apt-get virtualenv and pip virtualenv?
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.
What is the difference between package name and python-package name?
One of those names is the actual package name under which it is published to the Python Package Index (PyPI), which is the namespace that pip
deals in.
The other is the name as set by your Ubuntu operating system, and given the version string, I am guessing that you are using Ubuntu 18.04 Bionic Beaver. Ubuntu uses a strict naming convention, where all Python packages must start with a python-
prefix. These packages are managed and installed by your OS package manager.
How to proceed depends on your Jupyter setup. If it is installed and running from a virtualenv, then you can use the pip
command when the virtualenv is active to alter versions there. Take into account that using pip
should already ensure you are getting compatible versions installed; you could try to upgrade jupyter
if tornado
was upgraded independently.
If you are using the Ubuntu-managed jupyter package then there too the package manager should take care of matching versions.
However, if you you are using a virtualenv that still has access to the OS-mananged jupyter system while locally only tornado is installed, then you want to add jupyter to your virtualenv to mask the system version, which is too old.
Difference between 'python setup.py install' and 'pip install'
On the surface, both do the same thing: doing either python setup.py install
or pip install <PACKAGE-NAME>
will install your python package for you, with a minimum amount of fuss.
However, using pip offers some additional advantages that make it much nicer to use.
- pip will automatically download all dependencies for a package for you. In contrast, if you use
setup.py
, you often have to manually search out and download dependencies, which is tedious and can become frustrating. - pip keeps track of various metadata that lets you easily uninstall and update packages with a single command:
pip uninstall <PACKAGE-NAME>
andpip install --upgrade <PACKAGE-NAME>
. In contrast, if you install a package usingsetup.py
, you have to manually delete and maintain a package by hand if you want to get rid of it, which could be potentially error-prone. - You no longer have to manually download your files. If you use
setup.py
, you have to visit the library's website, figure out where to download it, extract the file, runsetup.py
... In contrast, pip will automatically search the Python Package Index (PyPi) to see if the package exists there, and will automatically download, extract, and install the package for you. With a few exceptions, almost every single genuinely useful Python library can be found on PyPi. - pip will let you easily install wheels, which is the new standard of Python distribution. More info about wheels.
- pip offers additional benefits that integrate well with using
virtualenv
, which is a program that lets you run multiple projects that require conflicting libraries and Python versions on your computer. More info. - pip is bundled by default with Python as of Python 2.7.9 on the Python 2.x series, and as of Python 3.4.0 on the Python 3.x series, making it even easier to use.
So basically, use pip. It only offers improvements over using python setup.py install
.
If you're using an older version of Python, can't upgrade, and don't have pip installed, you can find more information about installing pip at the following links:
- Official instructions on installing pip for all operating systems
- Instructions on installing pip on Windows (including solutions to common problems)
- Instructions on installing pip for Mac OX
pip, by itself, doesn't really require a tutorial. 90% of the time, the only command you really need is pip install <PACKAGE-NAME>
. That said, if you're interested in learning more about the details of what exactly you can do with pip, see:
- Quickstart guide
- Official documentation.
It is also commonly recommended that you use pip and virtualenv together. If you're a beginner to Python, I personally think it'd be fine to start of with just using pip and install packages globally, but eventually I do think you should transition to using virtualenv as you tackle more serious projects.
If you'd like to learn more about using pip and virtualenv together, see:
- Why you should be using pip and virtualenv
- A non-magical introduction to Pip and Virtualenv for Python beginners
- Virtual Environments
Related Topics
Python Udisks - Enumerating Device Information
Why Are Scripting Languages (E.G. Perl, Python, and Ruby) Not Suitable as Shell Languages
Pandas Add Column to Groupby Dataframe
Convert String in Base64 to Image and Save on Filesystem
Plotting a 3D Cube, a Sphere and a Vector in Matplotlib
Recursion and Return Statements
How to Make a Custom Activation Function with Only Python in Tensorflow
How to Avoid Floating Point Errors
Why Can Tuples Contain Mutable Items
Connect Wifi with Python or Linux Terminal
Which Key/Value Store Is the Most Promising/Stable
Negative Integer Division Surprising Result
How to Print a String at a Fixed Width
Python: Problem with Raw_Input Reading a Number
How to Remove Stop Words Using Nltk or Python
Why Isn't Pycharm's Autocomplete Working for Libraries I Install