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

2024-10-03 00:28:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我现在想清理我在MacBookPro上的安装。在过去,我安装了一些东西,比如自制程序、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/

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

^{pr2}$

实际上,任何与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等等),它将帮助我更好地理解这一点,并有助于我今后下载和安装文件/软件包的实践。在


Tags: installpip文件程序config权限错误library
1条回答
网友
1楼 · 发布于 2024-10-03 00:28:42

if anyone could help me clear up and explain what the relationship between these things are

homebrew是一个面向MAC操作系统的软件管理工具,它的行为类似于centos中的yum,ubuntu中的apt。在

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

pip(pip2,pip2.x,pip3,pip3.x)是一个针对python的包管理工具,与自制程序无关。在

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

例如,如果您运行

pip2.7 install requests

它将在/Library/Python/2.7/site-packages/安装“requests”软件包,您可以像这样使用它:

^{pr2}$

to clean and tidy up this mess, and uninstall all packages/programs I have previously installed that relates to 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开发环境。在

相关问题 更多 >