我想清理我的pip / homebrew / python安装

问题描述 投票:0回答:1

我想在我的MacBook Pro上清理我的装置。过去,我安装了自制软件,pip,python,nnpm以及其他一些我甚至不记得的东西。

最近,我尝试安装OpenCV软件包,但遇到了一些错误,导致我尝试更新pip,这导致了一些权限错误。查看stackoverflow,我尝试更改所涉及的文件和文件夹的一些权限:

sudo chmod -R 777 /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/EGG-INFO/
sudo chmod -R 777 /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/

现在,在运行最后一个命令并尝试更新pip pip install --upgrade pip后,我得到:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2696, in load_entry_point
    raise ImportError("Entry point %r not found" % ((group, name),))
ImportError: Entry point ('console_scripts', 'pip') not found

事实上,与pip命令有关(例如pip -V现在给出了同样的错误。

现在,我检查/usr/local/bin,看到一大堆文件。给你一个想法:ls /usr/local/bin回归

2to3                    install-info            pydoc3.6
2to3-3.6                makeinfo                python3
R                       node                    python3-32
RemoteUpdateManager     nosetests               python3-config
Rscript                 nosetests-2.7           python3.6
SophosUpdate            npm                     python3.6-32
VBoxAutostart           npx                     python3.6-config
VBoxBalloonCtrl         pdftexi2dvi             python3.6m
VBoxBugReport           pip                     python3.6m-config
VBoxDTrace              pip2                    pyvenv
VBoxHeadless            pip2.7                  pyvenv-3.6
VBoxManage              pip3                    sqlite3_analyzer
VBoxVRDP                pip3.6                  sweep
VirtualBox              pod2texi                tclsh8.6
brew                    prl_convert             texi2any
chardetect              prl_disk_tool           texi2dvi
chromedriver            prl_perf_ctl            texi2pdf
easy_install-3.6        prlcore2dmp             texindex
idle3                   prlctl                  vbox-img
idle3.6                 prlexec                 vboxwebsrv
info                    prlsrvctl               wish8.6
infokey                 pydoc3

我在计算机上看到了不同安装程序的相同内容的多个版本(如pip,pip2,pip2.7,pip3,pip3.6)。

.

我最终想要实现的是清理和整理这个混乱,并卸载我之前安装的与pip,python,homebrew,nnpm以及与这些相关的任何其他内容的所有软件包/程序。之后,我想重新安装我再次运行Python所需的东西,以及安装Python包,如numpy,OpenCV等。

此外,如果有人可以帮我清理并解释这些东西之间的关系(自制,pip,python等),它将有助于我更好地理解这一点,并有助于我未来的下载和安装文件/包的做法。

python macos pip install homebrew
1个回答
2
投票

如果有人能帮助我清理并解释这些事情之间的关系

homebrew是一个用于MAC OS的软件管理工具,它的行为类似于yum in centos,apt在ubuntu中。

npm是nodejs的包管理工具,它的行为类似于python的pip,perl的cpan

pip(pip2,pip2.x,pip3,pip3.x)是python的包管理工具,与homebrew没有任何关系。

“pip”后面的后缀表示它管理的是哪个python版本。你看到了几个pip工具,表明你已经安装了几个python版本。

例如,如果你跑

pip2.7 install requests

它将在/Library/Python/2.7/site-packages/上安装“请求”包,你可以使用它:

python2.7
>>>import requests
>>>requests.get("https://www.google.com")

清理和整理这个烂摊子,并卸载我之前安装的与pip,python,homebrew,nnpm有关的所有软件包/程序

# remove python from you mac
# I don't use mac, but I guess the command may be like this
brew uninstall python3
brew uninstall python2

# remove python related directories
rm -r /Library/Python/2.7
rm -r /Library/Python/3.6

# remove pip and other python related executers
rm /usr/local/bin/pip*
rm /usr/local/bin/python*

# now you can reinstall python and pip
# I'm not familiar with npm, but the principle is similar. 
# You can remove the npm by brew, and remove related executers and package directories

我强烈建议您不要在全球范围内安装软件包。

您应该始终使用virtualenv来管理您的python开发环境。

© www.soinside.com 2019 - 2024. All rights reserved.