They do exactly the same thing. In fact, the docs for distributing Python modules were just updated to suggest using python -m pip instead of the pip executable, because it's easier to tell which version of python is going to be used to actually run pip that way.
@joeforker, pip uses setup.py behind the scenes.
Pip is the standard package manager for Python. It allows us to install and manage additional packages that are not part of the Python standard library. Pip is an essential tool that comes along with python (after version 3.4 and 2.7. 9) to install new packages.
Use of Setup.py It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on. Secondly, it serves as the command line interface via which packaging commands may be executed.
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.
setup.py
, you often have to manually search out and download dependencies, which is tedious and can become frustrating.pip uninstall <PACKAGE-NAME>
and pip install --upgrade <PACKAGE-NAME>
. In contrast, if you install a package using setup.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.setup.py
, you have to visit the library's website, figure out where to download it, extract the file, run setup.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.virtualenv
, which is a program that lets you run multiple projects that require conflicting libraries and Python versions on your computer. More info.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:
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:
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:
python setup.py install
is the analog of make install: it’s a limited way to compile and copy files to destination directories. This doesn’t mean that it’s the best way to really install software on your system.
pip
is a package manager, which can install, upgrade, list and uninstall packages, like familiar package managers including: dpkg, apt, yum, urpmi, ports
etc. Under the hood, it will run python setup.py install
, but with specific options to control how and where things end up installed.
In summary: use pip
.
The question is about the preferred method to install a local tarball containing a python package, NOT about the advantage of uploading package to an indexing service like PyPi.
As lest I know some software distributor does not upload their package to PyPi, instead asking developers to download package from their website and install.
python setup.py install
This can work but not recommended. It's not necessary to unwrap the tarball file and go into it to run setup.py file.
pip install ../path/to/packagename.tar.gz
This is the way designed and preferred. Concise and align with PyPi-style packages.
More information about pip install
can be found here: https://pip.readthedocs.io/en/stable/reference/pip_install/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With