卸载用户在macOS High Sierra上使用pip安装的所有软件包 [英] Uninstall all the packages installed using pip by a user on macOS High Sierra
问题描述
由于错误,我使用pip在全局环境中安装了软件包.我想知道使用提供的说明在这里?或者有什么方法可以摆脱我使用pip安装的所有软件包及其依赖项.
By mistake I installed packages in the global environment using pip. I was wondering if its a good idea to uninstall the already existing Python on the OS using the instructions provided here, and re-install it using homebrew using the instructions provided over here? Or is there any way to get rid of all packages and their dependency I installed using pip.
我在macOS High Sierra上使用Python 2.7.10. 建议方法的问题:
I'm using Python 2.7.10 on macOS High Sierra. Problem with a suggested approach:
按照 CloC 在评论部分中的建议,我尝试通过键入
As suggested by CloC in the comments section, I tried uninstalling all packages from global environment by typing
pip freeze > to_delete.txt
然后
sudo -H pip uninstall -y -r to_delete.txt
但是我在终端中遇到以下错误:
However I got the following error in the terminal:
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'")]
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才能进行全新的软件包安装.
You certainly should not resinstall python to have a fresh package installation.
您可以通过首先列出并卸载它们来轻松地从全局环境中卸载所有软件包:
You can easily uninstall all packages from you global environment by firstly listing them and uninstalling them:
pip freeze > to_delete.txt
然后:
pip uninstall -y -r to_delete.txt
如果不想全部卸载,则可以删除要保留在第一步中创建的to_delete.txt
文件中的行.
If you do not want to uninstall all of them, you can delete the lines you want to keep in the to_delete.txt
file created in the first step.
这篇关于卸载用户在macOS High Sierra上使用pip安装的所有软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!