Monday, April 21, 2025

Python PIP How To - Install and Uninstall Packages

The "pip" command is a package installer for Python that allows you to easily install and manage third-party libraries or modules. In this case, the "send2trash" library is being installed, which provides a cross-platform way of sending files and folders to the recycle bin or trash instead of permanently deleting them. 

Pip gathers files for installation from the Python Package Index (PyPI), which is a repository of third-party Python packages. PyPI is a central repository of software packages for the Python programming language, where developers and users can publish, search for, and download packages.

When you use pip to install a package, pip searches the PyPI repository for the latest version of the package and downloads the package files from there. The package files can include source code, binary distributions, documentation, and metadata files, such as setup.py and README.md.

Pip also installs any dependencies that the package requires, by recursively searching for and downloading the necessary packages from PyPI.

Microsoft Windows [Version 10.0.18363.900]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\user>pip install send2trash
Collecting send2trash
  Downloading Send2Trash-1.5.0-py3-none-any.whl (12 kB)
Installing collected packages: send2trash
Successfully installed send2trash-1.5.0

C:\Users\user>

This is the output of running the command "pip install send2trash" in a Windows command prompt.

The output shows that the installation was successful, as the "Successfully installed send2trash-1.5.0" message indicates that the library was installed without any errors. 

C:\Users\user>pip uninstall send2trash
Found existing installation: Send2Trash 1.5.0
Uninstalling Send2Trash-1.5.0:
  Would remove:
    c:\python38-64\lib\site-packages\send2trash-1.5.0.dist-info\*
    c:\python38-64\lib\site-packages\send2trash\*
Proceed (y/n)? y
  Successfully uninstalled Send2Trash-1.5.0

C:\Users\user>

The output shows that there was an existing installation of Send2Trash 1.5.0, and it asks for confirmation to proceed with the uninstallation. After confirming by typing 'y', the output confirms that the library has been successfully uninstalled. The output indicates the files and directories that would be removed by the uninstallation process.

For most cases and for the vast majority of Python packages, pip is the most convenient and recommended way to install packages, as it handles dependency management and ensures that packages are installed to the correct location in the system.

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...