-
Uninstall:
- Windows: Use the Control Panel or the installer.
- macOS: Delete from the Applications folder.
- Linux: Use your package manager (e.g., sudo apt remove python3).
-
Install:
- Download from
python.org. - Install using the installer (Windows/macOS) or package manager (Linux).
- For Windows, check “Add Python to PATH.
- Download from
Installation & uninstallation of packages in Python
Key takeaways:
pipmakes it easy to install, uninstall, and upgrade Python packages, streamlining dependency management for developers.It connects to the Python Package Index (PyPI), allowing you to access thousands of third-party libraries and tools for various tasks.
With version control and automatic dependency handling,
piphelps maintain a clean and functional development environment.
In Python, you can install and uninstall packages using the pip tool, which is the standard package manager for Python. pip (short for “Pip Installs Packages”) is an essential tool that helps you manage third-party libraries and dependencies in your Python environment. It is included by default in Python installations from version 3.4 onwards, making it readily available for most Python users.
pip interacts with the Python Package Index (PyPI), a large repository that hosts thousands of Python libraries and packages, allowing developers to easily share and distribute their work. By using pip, developers can quickly install packages for a wide variety of purposes, such as data manipulation (pandas, numpy), web development (Flask, Django), machine learning (scikit-learn, tensorflow), and more.
Package
All the files needed for a module are contained in a package.
- Packages are installed based on the project requirement.
- Before you install packages, check if
pipis installed—if it’s not installed, download PIP.pipis a package manager for Python packages or modules.
Note: If you have Python version 3.4 or later,
PIPis included by default.
How to check the pip version
Go to command prompt and navigate to the Python directory as shown:
C:\Users\Your Name\AppData\Local\Programs\Python\Python36\Scripts>pip --version
Note: This is
C:\Users\Your Name\AppData\Local\Programs\Python\Python36\ScriptsPython directory in our case.
How to install a package
- Go to the command prompt.
- Navigate to the Python Scripts directory (as shown above).
- Now type:
pip install package-name
Example
C:\Users\Your Name\AppData\Local\Programs\Python\Python36\Scripts>pip install matplotlib
How to uninstall a package
- Use uninstall to remove the package.
Example
C:\Users\Your Name\AppData\Local\Programs\Python\Python36\Scripts>pip uninstall matplotlib
- It will ask whether to remove the package or not (y/n?) for confirmation.
yis for removing.nis for not removing.
Packages list
To check all the packages in Python, use the pip list command.
Example
C:\Users\Your Name\AppData\Local\Programs\Python\Python36\Scripts>pip list
- A list of installed packages will be displayed.
The same process is repeated for all the packages.
Try it yourself
Now, let’s try some of the previously mentioned commands in the widget below:
- Press the “Run” button.
- The console will appear in the current Python directory.
- Try running commands:
pip --versionpip install package_namepip uninstall package-namepip list
Start coding with confidence! “Learn Python 3 from Scratch” takes you through Python fundamentals and program structures, culminating in a practical project to solidify your skills.
Frequently asked questions
Haven’t found what you were looking for? Contact Us