本文主要介绍使用Python使用pip安装tld(pip install tld)时,报错(Cannot uninstall 'six')的解决方法。

具体错误信息如下

Collecting tld
  Using cached https://files.pythonhosted.org/packages/fa/78/dbeaeb20db795c42deb81271fd65a35c040ce2e946024eaeef5c6b...
Collecting six>=1.9 (from tld)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe30...
Installing collected packages: six, tld
  Found existing installation: six 1.4.1
Cannot uninstall 'six'. 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.

1、修改安装命令解决

遇到上述错误,尝试以下命令安装six-1.11.0和tld-0.9。

$ pip install tld --ignore-installed six --user
$ pip install tld --ignore-installed six --user
Collecting tld
Using cached https://files.pythonhosted.org/packages/fa/78/dbeaeb20db795c42deb81271fd65a35c040ce2e946024eaeef5c6b...
Collecting six
Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe30...
Installing collected packages: six, tld
Successfully installed six-1.11.0 tld-0.9

2、mac系统(mojave osx)中的解决方法

如果上述方法不能解决,可以尝试下列命令,更新一下:

brew update
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
brew reinstall python@2


推荐文档