python - 卸载用户在 macOS High Sierra 上使用 pip 安装的所有软件包

标签 python macos python-2.7 pip macos-high-sierra

我错误地使用 pip 在全局环境中安装了软件包。我想知道使用提供的说明在操作系统上卸载现有的 Python 是否是个好主意 here ,并按照提供的说明使用自制软件重新安装 over here ?或者有什么方法可以摆脱我使用 pip 安装的所有包及其依赖项。
我在 macOS High Sierra 上使用 Python 2.7.10。
编辑:建议方法的问题:
正如 CloC 所建议的在评论部分,我尝试通过键入从全局环境中卸载所有包

pip freeze > to_delete.txt
进而
sudo -H pip uninstall -y -r to_delete.txt
但是我在终端中收到以下错误:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/basecommand.py", line 141, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/commands/uninstall.py", line 74, in run
    auto_confirm=options.yes, verbose=self.verbosity > 0,
  File "/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/req/req_install.py", line 864, in uninstall
    uninstalled_pathset.remove(auto_confirm, verbose)
  File "/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/req/req_uninstall.py", line 221, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/utils/misc.py", line 276, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
    copytree(src, real_dst, symlinks=True)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
    raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/macholib/dyld.py', '/private/tmp/pip-uninstall-3QWFII/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/macholib/dyld.py', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-3QWFII/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/macholib/dyld.py'"), [...], "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-3QWFII/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/macholib'")]

最佳答案

您当然不应该重新安装 python 来安装全新的软件包。

您可以通过首先列出它们并卸载它们来轻松地从全局环境中卸载所有软件包:

pip freeze > to_delete.txt

进而:
pip uninstall -y -r to_delete.txt

如果不想全部卸载,可以删除to_delete.txt中要保留的行。第一步创建的文件。

关于python - 卸载用户在 macOS High Sierra 上使用 pip 安装的所有软件包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52398022/

相关文章:

python - 即使在设置 SLUGIFY_USES_TEXT_UNIDECODE 和 AIRFLOW_GPL_UNIDECODE 后也无法安装 Airflow

python - 证书过期,无法使用 certify=True; requests.exceptions.SSLError 证书验证失败

macos - 使用 NSPipe 配合 NSTask 模拟命令行输入

python - 从元类访问构造函数的参数

python - 如何报告异常以备后用

python - 如何用 pandas DataFrame 中之前和后续值的平均值替换 NaN?

node.js - 如何在 Mac 上使用 pm2 启动命令?

java - 在 Mountain Lion Mac OSX 上使用 Java 制作 .app 文件

python - Bottle :全局变量 'request' 未定义

linux - repo 无法在 Macbook 上的 Ubuntu 16,0 虚拟机上初始化