Pip 无法卸载 Python 中的 错误 [已解决]

目录

Pip cannot uninstall <package> error solved in Python

  1. Python中pip无法卸载包错误
  2. 无法卸载 Python 中的“PyYAML”错误
  3. 无法在 Python 中卸载“llvmlite”
  4. 无法在 Python 中卸载“certifi”
  5. 无法卸载 Python 中的“numpy”错误
  6. 无法卸载 Python 中的“wrap”

Python中pip无法卸载包错误

当我们使用操作系统的包管理器安装并尝试使用pip.

要解决该错误,请使用--ignore-installed选项,例如
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.

卸载PyYAML、、、
经常出现该错误
llvmlitenumpycertifiwrapt

要解决该错误,请pip install使用
–ignore-installed
选项运行命令。

确保替换requests为错误消息中的包。

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 permissions error sudo pip install --ignore-installed requests sudo pip3 install --ignore-installed requests

如果您尝试安装另一个依赖于 的软件包requests,请在运行该pip install --ignore-installed requests命令后安装它。

如果您尝试删除特定包,请运行以下命令。

sudo apt-get remove python-requests pip uninstall requests pip3 uninstall requests
--ignore-installed选项会忽略已安装的软件包并覆盖它们。

这有帮助,因为错误的最常见原因是使用操作系统的包管理器(或 Anaconda)安装模块并尝试使用更新或删除包pip

--ignore-installed选项忽略已安装的包并覆盖它。

安装软件包之前停用虚拟环境

如果该建议没有帮助并且您处于虚拟环境中,请先尝试停用它。

# 👇️ 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

确保替换requests为错误消息中的包。

conda update如果您使用 Anaconda 安装软件包,请尝试使用

如果您使用 Anaconda 安装该软件包并尝试使用 更新它
pip,请使用该conda update命令。

conda update requests

如果该软件包是使用 Anaconda 安装的,您将能够使用该conda update命令更新它。

您可以尝试的另一件事是使用该conda remove命令。

conda remove requests

使用 删除软件包后conda remove,您可以使用该pip install
命令来安装它。

conda update --all您还可以尝试在安装软件包之前运行该命令。

conda update --all

尝试在虚拟环境中安装包

如果错误未解决并且您不在虚拟环境中,请尝试创建一个。

  1. 创建虚拟环境。
  2. 激活虚拟环境。
  3. pip install在虚拟环境处于活动状态时运行命令。
# 👇️ use 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

确保根据您的操作系统使用正确的激活命令。

您的虚拟环境将使用用于创建它的 Python 版本。

创建虚拟环境并在其中安装包会有所帮助,因为虚拟环境是独立的 Python 安装。

解决特定包错误的示例

以下是如何解决特定包的错误的一些示例。

目录

  1. 无法卸载 Python 中的“PyYAML”错误
  2. 无法在 Python 中卸载“llvmlite”
  3. 无法在 Python 中卸载“certifi”
  4. 无法卸载 Python 中的“numpy”错误
  5. 无法卸载 Python 中的“wrap”

无法卸载 Python 中的“PyYAML”错误

PyYAML
当我们使用操作系统的包管理器
安装包并尝试使用 更新或删除包时,会出现错误“无法卸载‘PyYAML’”
pip

要解决该错误,请使用--ignore-installed选项,例如
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.

要解决该错误,请pip install使用
–ignore-installed
选项运行命令。

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 permissions error sudo pip install --ignore-installed PyYAML sudo pip3 install --ignore-installed PyYAML
--ignore-installed选项会忽略已安装的软件包并覆盖它们。

这有帮助,因为错误的最常见原因是
使用操作系统的包管理器(或 Anaconda)
安装
PyYAMLpip模块并尝试使用更新或删除包。

--ignore-installed选项会忽略已安装的PyYAML软件包并覆盖它。

如果您使用 Anaconda 进行安装PyYAML并尝试使用 更新它
pip,请改用该conda update命令。

conda update PyYAML

如果该软件包是使用 Anaconda 安装的,您将能够使用该conda update命令更新它。

您可能尝试的另一件事是使用该conda remove PyYAML命令,但这可能不是一个好主意,因为您环境中的其他软件包可能依赖于PyYAML,这意味着您也必须重新安装它们。

尝试在虚拟环境中安装包

如果错误未解决并且您不在虚拟环境中,请尝试创建一个。

  1. 创建虚拟环境。
  2. 激活虚拟环境。
  3. pip install PyYAML在虚拟环境处于活动状态时运行命令。
# 👇️ use 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 virtual environment pip install PyYAML

确保根据您的操作系统使用正确的激活命令。

您的虚拟环境将使用用于创建它的 Python 版本。

创建虚拟环境并PyYAML在其中安装会有所帮助,因为虚拟环境是独立的 Python 安装。

错误:无法在 Python 中卸载“llvmlite”

当我们安装依赖于llvmlite操作系统的包管理器的包并尝试使用pip.

要解决该错误,请使用--ignore-installed选项,例如
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.

要解决该错误,请pip install使用
–ignore-installed
选项运行命令。

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 permissions error sudo pip install --ignore-installed llvmlite sudo pip3 install --ignore-installed llvmlite

安装llvmlite软件包后,您可以运行pip install命令来安装您最初尝试安装的软件包,例如nemo_toolkit

pip install "nemo_toolkit[all]"
--ignore-installed选项会忽略已安装的软件包并覆盖它们。

这有帮助,因为错误的最常见原因是使用操作系统的包管理器(或 Anaconda)安装依赖于llvmlitepip模块的包,并尝试使用更新或删除包。

--ignore-installed选项会忽略已安装的llvmlite软件包并覆盖它。

如果您使用 Anaconda 安装该软件包并尝试使用 更新它
pip,请conda update llvmlite首先使用该命令。

conda update llvmlite pip install "nemo_toolkit[all]"

如果该软件包是使用 Anaconda 安装的,您将能够使用该conda update命令更新它。

conda remove llvmlite您可以尝试的另一件事是在安装软件包之前使用该命令。

conda remove llvmlite pip install "nemo_toolkit[all]"

尝试在虚拟环境中安装包

如果错误未解决并且您不在虚拟环境中,请尝试创建一个。

  1. 创建虚拟环境。
  2. 激活虚拟环境。
  3. pip install在虚拟环境处于活动状态时运行命令。
# 👇️ use 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]"

确保根据您的操作系统使用正确的激活命令。

您的虚拟环境将使用用于创建它的 Python 版本。

创建虚拟环境并在其中安装包会有所帮助,因为虚拟环境是独立的 Python 安装。

错误:无法在 Python 中卸载“certifi”

当我们安装依赖于certifi操作系统的包管理器的包并尝试使用pip.

要解决该错误,请使用--ignore-installed选项,例如
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.

要解决该错误,请pip install使用
–ignore-installed
选项运行命令。

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 permissions error sudo pip install --ignore-installed certifi sudo pip3 install --ignore-installed certifi

安装certifi包后,您可以运行pip install命令来安装您最初尝试安装的包。

--ignore-installed选项会忽略已安装的软件包并覆盖它们。

这会有所帮助,因为错误的最常见原因是使用操作系统的包管理器(或 Anaconda)安装依赖于certifipip模块的包,并尝试使用.

--ignore-installed选项会忽略已安装的certifi软件包并覆盖它。

如果您使用 Anaconda 安装该软件包并尝试使用 更新它
pip,请conda update certifi首先使用该命令。

conda update certifi # 👇️ install the other package that depends on certifi pip install requests

如果该软件包是使用 Anaconda 安装的,您将能够使用该conda update命令更新它。

conda remove certifi您可以尝试的另一件事是在安装软件包之前使用该命令。

conda remove certifi # 👇️ install the other package that depends on certifi pip install requests

尝试在虚拟环境中安装包

如果错误未解决并且您不在虚拟环境中,请尝试创建一个。

  1. 创建虚拟环境。
  2. 激活虚拟环境。
  3. pip install在虚拟环境处于活动状态时运行命令。
# 👇️ use 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

确保根据您的操作系统使用正确的激活命令。

您的虚拟环境将使用用于创建它的 Python 版本。

创建虚拟环境并在其中安装包会有所帮助,因为虚拟环境是独立的 Python 安装。

无法卸载 Python 中的 ‘numpy’ 错误

numpy当我们使用操作系统的包管理器安装包并尝试使用 更新或删除包时,会出现错误“无法卸载‘numpy’” pip

要解决该错误,请使用--ignore-installed选项,例如
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.

要解决该错误,请pip install使用
–ignore-installed
选项运行命令。

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 permissions error sudo pip install --ignore-installed numpy sudo pip3 install --ignore-installed numpy

如果您尝试安装另一个依赖于 的软件包numpy,请在运行该pip install --ignore-installed numpy命令后安装它。

如果您尝试删除numpy,请运行以下命令。

sudo apt-get remove python-numpy pip uninstall numpy pip3 uninstall numpy
--ignore-installed选项会忽略已安装的软件包并覆盖它们。

这有帮助,因为错误的最常见原因是
使用操作系统的包管理器(或 Anaconda)
安装
numpypip模块并尝试使用更新或删除包。

--ignore-installed选项会忽略已安装的numpy软件包并覆盖它。

如果您使用 Anaconda 进行安装numpy并尝试使用 进行更新pip,请使用该conda update numpy命令。

conda update numpy

如果该软件包是使用 Anaconda 安装的,您将能够使用该conda update命令更新它。

您可以尝试的另一件事是使用该conda remove numpy命令。

conda remove numpy

使用 删除软件包后conda remove,您可以使用该pip install
命令来安装它。

尝试在虚拟环境中安装包

如果错误未解决并且您不在虚拟环境中,请尝试创建一个。

  1. 创建虚拟环境。
  2. 激活虚拟环境。
  3. 在虚拟环境处于活动状态时运行pip install numpy命令。
# 👇️ use 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 virtual environment pip install numpy

确保根据您的操作系统使用正确的激活命令。

您的虚拟环境将使用用于创建它的 Python 版本。

创建虚拟环境并numpy在其中安装会有所帮助,因为虚拟环境是独立的 Python 安装。

错误:无法在 Python 中卸载“wrapt”

当我们使用操作系统的包管理器安装tensorflow包并尝试使用更新或删除包时,会出现“无法卸载‘wrapt’”错误
pip

要解决该错误,请使用--ignore-installed选项,例如
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.

要解决该错误,请pip install使用
–ignore-installed
选项运行命令。

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 permissions error sudo pip install --ignore-installed wrapt sudo pip install tensorflow sudo pip3 install --ignore-installed wrapt sudo pip3 install tensorflow
--ignore-installed选项会忽略已安装的软件包并覆盖它们。

这会有所帮助,因为错误的最常见原因是
使用操作系统的包管理器(或 Anaconda)安装
tensorflowpip模块并尝试使用.

--ignore-installed选项会忽略已安装的wrapt软件包并覆盖它。

如果您使用 Anaconda 进行安装tensorflow并尝试使用 更新它
pip,请conda update wrapt首先使用该命令。

conda update wrapt pip install tensorflow

如果该软件包是使用 Anaconda 安装的,您将能够使用该conda update命令更新它。

conda remove wrapt您可以尝试的另一件事是在安装之前使用该命令tensorflow

conda remove wrapt pip install tensorflow

尝试在虚拟环境中安装包

如果错误未解决并且您不在虚拟环境中,请尝试创建一个。

  1. 创建虚拟环境。
  2. 激活虚拟环境。
  3. pip install tensorflow在虚拟环境处于活动状态时运行命令。
# 👇️ use 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 virtual environment pip install tensorflow

确保根据您的操作系统使用正确的激活命令。

您的虚拟环境将使用用于创建它的 Python 版本。

创建一个虚拟环境并tensorflow在其中安装会有所帮助,因为虚拟环境是一个独立的 Python 安装。