Master Python Package Management: distutils, setuptools, pip & More
This article explains the relationships and differences among Python's package management tools—including distutils, setuptools, distribute, easy_install, and pip—showing how to create packages with setup.py, install them, and choose the right tool for various scenarios.
Python Package Management Tools
Python offers a variety of package management tools, and understanding their relationships helps developers choose the appropriate one.
distutils
distutils is part of the Python standard library and provides a simple way to package and install modules via setup.py.
from distutils.core import setup
setup(
name='fooBar',
version='1.0',
author='Will',
author_email='[email protected]',
url='http://www.cnblogs.com/wilber2013/',
py_modules=['foo', 'bar'],
)Running python setup.py sdist creates a fooBar-1.0.zip package, which can be installed with python setup.py install.
After installation, the modules foo and bar become available.
setuptools and distribute
setuptools extends distutils with dependency management and supports the .egg format.
distribute was a fork of setuptools that has since merged back, so they are effectively the same.
easy_install
After installing setuptools/distribute, easy_install can be used to install packages directly from PyPI, local archives, or .egg files.
pip
pipis now the most popular Python package manager, serving as a replacement for easy_install while still relying on setuptools for many functions.
pip resolves several shortcomings of easy_install, such as non‑atomic installations, lack of uninstall command, and limited version control.
Installing pip
Two common methods:
Download get-pip.py and run python get-pip.py (it also installs setuptools if missing).
Download the pip source and install via setup.py.
Common pip commands
pip install SomePackage– install a package from PyPI. pip uninstall SomePackage – uninstall a package. pip list – list installed packages. pip list --outdated – show packages with newer versions. pip install --upgrade SomePackage – upgrade a package. pip show --files SomePackage – display files installed by a package. pip install SomePackage==1.0.4 – install a specific version. pip freeze > requirements.txt – export installed packages to a requirements file. pip install -r requirements.txt – install packages from a requirements file.
Conclusion
The article outlines the relationships among Python's package management tools—distutils, setuptools, distribute, easy_install, and pip—helping readers understand their purposes and choose the appropriate tool for their workflow.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
