19. Python PIP
Python PIP
PIP is a package manager for Python packages, or modules if you like. If you have Python version 3.4 or later, PIP is included by default.
A package contains all the files you need for a module. Modules are Python code libraries you can include in your project. PIP allows you to download, install, and manage these third-party packages effortlessly from the Python Package Index (PyPI).
Checking if PIP is Installed
Navigate to your command line (Command Prompt, Terminal, or Bash) and type the following command to check if PIP is installed and to see its version.
If you see a version number, PIP is ready to use. If you get a "command not found" error, you may need to use pip3 --version instead, depending on your operating system setup.
Installing a Package
Downloading a package is incredibly easy. Open your command line interface and tell PIP to download the package you want by using the install command.
Let's install a popular package called camelcase, which provides a method to capitalize the first letter of every word.
Using a Package
Once the package is installed, it is ready to use in your Python scripts. You import it exactly the same way you import Python's built-in modules.
Listing Packages
Over time, you will install many packages. Use the list command in your terminal to see all the packages currently installed on your system or in your environment.
Uninstalling a Package
If you no longer need a package, you can cleanly remove it using the uninstall command. PIP will ask you to confirm before proceeding.
Knowledge Check
Ready to test your understanding of 19. Python PIP?