Last updated: Apr 9, 2024
Reading timeยท12 min
The Python error "Cannot uninstall [package]" occurs when we install a package
with the operating system's package manager and try to update or remove the
package using pip
.
To solve the error, use the --ignore-installed
option, e.g.
pip install --ignore-installed <package-name>
.
Installing collected packages:<package-name> Found existing installation:<package-name> Cannot uninstall <package-name>. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
The error often occurs when uninstalling PyYAML
, llvmlite
, numpy
,
certifi
or wrapt
.
To solve the error, run the pip install
command with the
--ignore-installed
option.
Make sure to replace requests
with the package from your error message.
pip install --ignore-installed requests pip3 install --ignore-installed requests # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --ignore-installed requests python3 -m pip install --ignore-installed requests # ๐๏ธ If you get a permissions error sudo pip install --ignore-installed requests sudo pip3 install --ignore-installed requests
If you were trying to install another package that depends on requests
,
install it after running the pip install --ignore-installed requests
command.
If you were trying to remove a specific package, run the following command.
sudo apt-get remove python-requests pip uninstall requests pip3 uninstall requests
--ignore-installed
option ignores the installed packages and overwrites them.This helps because the most common cause of the error is installing a module
with the operating system's package manager (or Anaconda) and trying to update
or remove the package using pip
.
The --ignore-installed
option ignores the installed package and overwrites it.
If the suggestion didn't help and you are inside a virtual environment, try deactivating it first.
# ๐๏ธ Deactivate virtual environment deactivate # ๐๏ธ Install the package from your error message pip install --ignore-installed requests pip3 install --ignore-installed requests python -m pip install --ignore-installed requests python3 -m pip install --ignore-installed requests sudo pip install --ignore-installed requests sudo pip3 install --ignore-installed requests # ๐๏ธ Activate virtual env on Unix or macOS source venv/bin/activate # ๐๏ธ Activate virtual env on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate virtual env on Windows (PowerShell) venv\Scripts\Activate.ps1
Make sure to replace requests
with the package from your error message.
conda update
if you used Anaconda to install the packageIf you used Anaconda to install the package and are trying to update it using
pip
, use the conda update
command.
conda update requests
If the package was installed using Anaconda, you will be able to update it using
the conda update
command.
Another thing you might try is to use the conda remove
command.
conda remove requests
Once the package is removed using conda remove
, you can use the pip install
command to install it.
You can also try running the conda update --all
command before installing the
package.
conda update --all
If the error is not resolved and you aren't in a virtual environment, try creating one.
pip install
command with the virtual environment active.# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ install requests in a virtual environment pip install requests
If the python3 -m venv venv
command doesn't work, try one of the following 2
commands:
python -m venv venv
py -m venv venv
Make sure to use the correct activation command depending on your operating system.
Your virtual environment will use the version of Python that was used to create it.
Creating a virtual environment and installing the package inside it helps because the virtual environment is an isolated Python installation.
Here are some examples of how to solve the error for specific packages.
The error "Cannot uninstall 'PyYAML'" occurs when we install the PyYAML
package with the operating system's package manager and try to update or remove
the package using pip
.
To solve the error, use the --ignore-installed
option, e.g.
pip install --ignore-installed PyYAML
.
Installing collected packages: PyYAML Found existing installation: PyYAML Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
To solve the error, run the pip install
command with the
--ignore-installed
option.
pip install --ignore-installed PyYAML pip3 install --ignore-installed PyYAML # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --ignore-installed PyYAML python3 -m pip install --ignore-installed PyYAML # ๐๏ธ If you get a permissions error sudo pip install --ignore-installed PyYAML sudo pip3 install --ignore-installed PyYAML
--ignore-installed
option ignores the installed packages and overwrites them.This helps because the most common cause of the error is installing the
PyYAML module with the operating system's
package manager (or Anaconda) and trying to update or remove the package using
pip
.
The --ignore-installed
option ignores the installed PyYAML
package and
overwrites it.
If you used Anaconda to install PyYAML
and are trying to update it using
pip
, use the conda update
command instead.
conda update PyYAML
If the package was installed using Anaconda, you will be able to update it using
the conda update
command.
Another thing you might try is to use the conda remove PyYAML
command, but
that might not be a good idea because other packages in your environment might
depend on PyYAML
, which means that you would have to reinstall them as well.
If the error is not resolved and you aren't in a virtual environment, try creating one.
pip install PyYAML
command with the virtual environment active.# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ Install PyYAML in your virtual environment pip install PyYAML
Make sure to use the correct activation command depending on your operating system.
Your virtual environment will use the version of Python that was used to create it.
Creating a virtual environment and installing PyYAML
inside of it helps
because the virtual environment is an isolated Python installation.
The error "Cannot uninstall 'llvmlite'" occurs when we install a package that
depends on llvmlite
with the operating system's package manager and try to
update or remove the package using pip
.
To solve the error, use the --ignore-installed
option, e.g.
pip install --ignore-installed llvmlite
.
ERROR: Cannot uninstall 'llvmlite'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
To solve the error, run the pip install
command with the
--ignore-installed
option.
pip install --ignore-installed llvmlite pip3 install --ignore-installed llvmlite # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --ignore-installed llvmlite python3 -m pip install --ignore-installed llvmlite # ๐๏ธ If you get a permissions error sudo pip install --ignore-installed llvmlite sudo pip3 install --ignore-installed llvmlite
After you install the llvmlite
package, you can run the pip install
command
to install the package you initially tried to install, e.g. nemo_toolkit
.
pip install "nemo_toolkit[all]"
--ignore-installed
option ignores the installed packages and overwrites them.This helps because the most common cause of the error is installing a package
that depends on the llvmlite module with
the operating system's package manager (or Anaconda) and trying to update or
remove the package using pip
.
The --ignore-installed
option ignores the installed llvmlite
package and
overwrites it.
If you used Anaconda to install the package and are trying to update it using
pip
, use the conda update llvmlite
command first.
conda update llvmlite pip install "nemo_toolkit[all]"
If the package was installed using Anaconda, you will be able to update it using
the conda update
command.
Another thing you might try is to use the conda remove llvmlite
command before
installing the package.
conda remove llvmlite pip install "nemo_toolkit[all]"
If the error is not resolved and you aren't in a virtual environment, try creating one.
pip install
command with the virtual environment active.# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ install the package in the virtual environment pip install "nemo_toolkit[all]"
Make sure to use the correct activation command depending on your operating system.
Your virtual environment will use the version of Python that was used to create it.
Creating a virtual environment and installing the package inside it helps because the virtual environment is an isolated Python installation.
The error "Cannot uninstall 'certifi'" occurs when we install a package that
depends on certifi
with the operating system's package manager and try to
update or remove the package using pip
.
To solve the error, use the --ignore-installed
option, e.g.
pip install --ignore-installed certifi
.
ERROR: Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
To solve the error, run the pip install
command with the
--ignore-installed
option.
pip install --ignore-installed certifi pip3 install --ignore-installed certifi # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --ignore-installed certifi python3 -m pip install --ignore-installed certifi # ๐๏ธ If you get a permissions error sudo pip install --ignore-installed certifi sudo pip3 install --ignore-installed certifi
After you install the certifi
package, you can run the pip install
command
to install the package you initially tried to install.
--ignore-installed
option ignores the installed packages and overwrites them.This helps because the most common cause of the error is installing a package
that depends on the certifi module with the
operating system's package manager (or Anaconda) and trying to update or remove
the package using pip
.
The --ignore-installed
option ignores the installed certifi
package and
overwrites it.
If you used Anaconda to install the package and are trying to update it using
pip
, use the conda update certifi
command first.
conda update certifi # ๐๏ธ Install the other package that depends on certifi pip install requests
If the package was installed using Anaconda, you will be able to update it using
the conda update
command.
Another thing you might try is to use the conda remove certifi
command before
installing the package.
conda remove certifi # ๐๏ธ install the other package that depends on certifi pip install requests
If the error is not resolved and you aren't in a virtual environment, try creating one.
pip install
command with the virtual environment active.# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ Install the package in the virtual environment pip install requests
Make sure to use the correct activation command depending on your operating system.
Your virtual environment will use the version of Python that was used to create it.
Creating a virtual environment and installing the package inside it helps because the virtual environment is an isolated Python installation.
The error "Cannot uninstall 'numpy'" occurs when we install the numpy
package
with the operating system's package manager and try to update or remove the
package using pip
.
To solve the error, use the --ignore-installed
option, e.g.
pip install --ignore-installed numpy
.
Installing collected packages: numpy Found existing installation: numpy Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
To solve the error, run the pip install
command with the
--ignore-installed
option.
pip install --ignore-installed numpy pip3 install --ignore-installed numpy # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --ignore-installed numpy python3 -m pip install --ignore-installed numpy # ๐๏ธ If you get a permissions error sudo pip install --ignore-installed numpy sudo pip3 install --ignore-installed numpy
If you were trying to install another package that depends on numpy
, install
it after running the pip install --ignore-installed numpy
command.
If you were trying to remove numpy
, run the following command.
sudo apt-get remove python-numpy pip uninstall numpy pip3 uninstall numpy
--ignore-installed
option ignores the installed packages and overwrites them.This helps because the most common cause of the error is installing the
numpy module with the operating system's
package manager (or Anaconda) and trying to update or remove the package using
pip
.
The --ignore-installed
option ignores the installed numpy
package and
overwrites it.
If you used Anaconda to install numpy
and are trying to update it using pip
,
use the conda update numpy
command.
conda update numpy
If the package was installed using Anaconda, you will be able to update it using
the conda update
command.
Another thing you might try is to use the conda remove numpy
command.
conda remove numpy
Once the package is removed using conda remove
, you can use the pip install
command to install it.
If the error is not resolved and you aren't in a virtual environment, try creating one.
# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ Install numpy in your virtual environment pip install numpy
Make sure to use the correct activation command depending on your operating system.
Your virtual environment will use the version of Python that was used to create it.
Creating a virtual environment and installing numpy
inside of it helps because
the virtual environment is an isolated Python installation.
The error "Cannot uninstall 'wrapt'" occurs when we install the
tensorflow package with the operating
system's package manager and try to update or remove the package using pip
.
To solve the error, use the --ignore-installed
option, e.g.
pip install --ignore-installed wrapt
.
Installing collected packages: wrapt, tensorflow Found existing installation: wrapt ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
To solve the error, run the pip install
command with the
--ignore-installed
option.
pip install --ignore-installed wrapt pip install tensorflow pip3 install --ignore-installed wrapt pip3 install tensorflow # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --ignore-installed wrapt python -m pip install tensorflow python3 -m pip install --ignore-installed wrapt python3 -m pip install tensorflow # ๐๏ธ If you get a permissions error sudo pip install --ignore-installed wrapt sudo pip install tensorflow sudo pip3 install --ignore-installed wrapt sudo pip3 install tensorflow
--ignore-installed
option ignores the installed packages and overwrites them.This helps because the most common cause of the error is installing the
tensorflow module with the operating
system's package manager (or Anaconda) and trying to update or remove the
package using pip
.
The --ignore-installed
option ignores the installed wrapt
package and
overwrites it.
If you used Anaconda to install tensorflow
and are trying to update it using
pip
, use the conda update wrapt
command first.
conda update wrapt pip install tensorflow
If the package was installed using Anaconda, you will be able to update it using
the conda update
command.
Another thing you might try is to use the conda remove wrapt
command before
installing tensorflow
.
conda remove wrapt pip install tensorflow
If the error is not resolved and you aren't in a virtual environment, try creating one.
pip install tensorflow
command with the virtual environment active.# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ Install tensorflow in your virtual environment pip install tensorflow
Make sure to use the correct activation command depending on your operating system.
Your virtual environment will use the version of Python that was used to create it.
Creating a virtual environment and installing tensorflow
inside it helps
because the virtual environment is an isolated Python installation.