我错误地使用 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/