Open In App

How to Force pip to Reinstall a Package?

Last Updated : 23 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

It is common for library files to get corrupted with time for a programming language. In such cases, it may break the code in inexplicable ways. To resolve such issues, the library files need to be reinstalled a new to fix the problems. Here, we will learn how to force pip to reinstall the current version. There could be two situations in which the reinstall of the current version is required:

  • Reinstalling the current version of the pip
  • Reinstalling the current version of a library

Since all of this could be performed from the command line, only the statements producing the effects would be described, and if you’re using a pip version that is less than 10.0, it’s time to update pip using the following command:

pip install --upgrade pip

Reinstalling the current version of the pip

It may be required that pip by itself may be needed to be reinstalled. Where all the previously mentioned switches are used. Just the pip library is replaced at the position of the package name (as pip by itself is also a package). The command for which would be:

pip install --upgrade --force-reinstall pip

Example:

 In the following example, pip would be reinstalled:

python -m pip install --upgrade --force-reinstall pip

 

Reinstalling the current version of a library

To uninstall an installed library from your Python distribution, the command would be:

pip install --upgrade --no-deps --force-reinstall <package_name>

Where

--upgrade: Upgrade all specified packages to the newest available version. 
  • –no-deps: Don’t install package dependencies.
  • –force-reinstall: Reinstall all packages even if they are already up-to-date.
  • <package_name> is the name of the package to be installed. 

Note: *The reason for the inclusion of –no-deps switch is done assuming that the dependencies don’t require a reinstall.

Example: 

To reinstall the library NumPy, the command would be:

pip install --upgrade --no-deps --force-reinstall numpy

 

Reinstalling without removing the current versions

If, for some reason, you want to re-install <corrupted package> and all its dependencies without first removing the current versions, you can run:

pip install --ignore-installed <corrupted package>

Related Articles: Python PIP – GeeksforGeeks


Similar Reads

How to install Python3 and PIP on Godaddy Server?
GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. It’s a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. Python is an open-source, cross-platform, high-level, general-purpose programming language created by G
2 min read
Download and install pip Latest Version
PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI). After you have successfully installed Python, you would clearly need pip in order to install packages, such as Numpy, Django and lots more on your
2 min read
How to install pip in macOS ?
Before we start with how to install pip for Python on macOS, let's first go through the basic introduction to Python. Python is a widely-used general-purpose, high-level programming language. Python is a programming language that lets you work quickly and integrate systems more efficiently. PIP is a package management system used to install and man
2 min read
How to install Python libraries without using the pip command?
The most common practice of installing external libraries in your system is by using the Python pip command. However, there is an alternate method of manually installing Python libraries without using the pip command. In this article, we are going to discuss how to manually install a python package. Below is the Step-by-step approach to manually in
1 min read
Linux - Installing PIP to Manage Python Packages
Python is the most popular language for a decade, and we all know that python had a huge support of libraries that are used in different sectors of Software Engineering. Meanwhile, PIP also getting its fame along with python in Linux and developers community.PIP is a package manager for python in handling the software packages that are developed us
2 min read
11 pip Commands For Python Developers
Python has been preferred over all programming languages for technological advancement. It is one of the most lucrative programming languages that is used as the main programming language by more than 80%of developers. It is used for web development, mobile applications, hardware programming, and many more. Pip commands cannot be ignored when we ta
5 min read
Install Packages Using PIP With requirements.txt File in Python
Installing more than one package in Python simultaneously is a common requirement for any user migrating between operating systems. Most users are unaware of the availability of batch installing all the packages. They default to manually installing each library one after the other, which is time-consuming. This article will teach you how to install
2 min read
Python PIP
In this article, we will discuss what is PIP, and how to install, upgrade, and uninstall packages using Python PIP. So before starting and using it, let us understand what is a Python PIP. What is Package in Python?Package refers to a distribution of Python code that includes one or more modules or libraries. These packages are typically published
5 min read
How to Upgrade Pip and Python on Windows, Linux, and MacOS?
Python is a programming language with standard libraries and a great ecosystem of third-party packages. On the other side, Pip is the default package manager for Python that installs, upgrades and manages Python, including its dependencies. Pip simplifies the process of installing external libraries and tools which are written in Python. Pip allows
5 min read
"How to Fix 'jupyter: command not found' Error After Installing with pip "
In this discourse, we will explore the resolution for the 'jupyter: command not found' error that may arise after installing Jupyter using the pip command. We will discuss methods to address this issue, as installing Jupyter, a valuable tool for data work and analysis in Python, can sometimes lead to encountering the mentioned error. This article o
4 min read
Practice Tags :