简体   繁体   English

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

[英]I want to clean up my pip/homebrew/python installations

I want to clean up my installations on my MacBook Pro at the moment. 我现在想清理MacBook Pro上的安装。 In the past, I have installed things like homebrew, pip, python, nnpm and some other things that I don't even remember. 过去,我安装了自制软件,pip,python,nnpm之类的东西,以及一些我什至不记得的东西。

Recently, I tried to install the OpenCV package, but was met with some errors, which led my to try to update pip, which lead me to some permission errors. 最近,我尝试安装OpenCV软件包,但是遇到了一些错误,这导致我尝试更新pip,这导致了一些权限错误。 Looking around stackoverflow, I tried to change some permissions of the files and folders involved: 环顾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/

Now, after running that last command and trying to update pip pip install --upgrade pip , I get: 现在,在运行最后一条命令并尝试更新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

In fact, anything to do with pip commands (eg pip -V now give about the same error. 实际上,与pip命令有关的任何事情(例如pip -V现在都会产生相同的错误。

Now, I check /usr/local/bin and see a huge mess of files. 现在,我检查/usr/local/bin并看到一大堆文件。 To give you an idea: ls /usr/local/bin returns 给你一个想法: 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

I see Multiple versions of the same things (like pip, pip2, pip2.7, pip3, pip3.6) for different installed programs on my computer. 我在计算机上看到了不同版本的相同内容(例如pip,pip2,pip2.7,pip3,pip3.6)。

.

What I would ultimately like to achieve is to clean and tidy up this mess, and uninstall all packages/programs I have previously installed that relates to pip, python, homebrew, nnpm and anything else related to these. 我最终想要实现的是清理并整理此混乱情况,并卸载我以前安装的所有与pip,python,homebrew,nnpm相关的软件包/程序。 After which, I would like to reinstall the things needed for me to run Python again, as well as install Python packages such as numpy, OpenCV, etc. 之后,我想重新安装再次运行Python所需的东西,以及安装numpy,OpenCV等Python软件包。

Also, if anyone could help me clear up and explain what the relationship between these things are (homebrew, pip, python, etc), it would help me understand this better and aid in my future practices of downloading and installing files/packages. 此外,如果有人可以帮助我弄清并解释这些事物之间的关系(自制,pip,python等),则将有助于我更好地理解这一点,并有助于我以后下载和安装文件/软件包的实践。

if anyone could help me clear up and explain what the relationship between these things are 如果有人可以帮助我清理并解释这些事物之间的关系是什么

homebrew is a software management tool for MAC OS, it behaves like yum in centos, apt in ubuntu. homebrew是一种用于MAC OS的软件管理工具,其行为类似于centos中的yum,适用于ubuntu中的。

npm is a package management tool for nodejs, it behaves like pip for python, cpan for perl npm是用于nodejs的软件包管理工具,其行为类似于python的pip,perl的cpan

pip(pip2, pip2.x, pip3, pip3.x) is a package management tool for python, has no relationship with homebrew. pip(pip2,pip2.x,pip3,pip3.x)是python的软件包管理工具,与自制软件无关。

The suffix after "pip" indicates which python version it manages. “ pip”后的后缀表示它管理的是哪个python版本。 You saw several pip tool, indicates you have installed several python versions. 您看到了几个pip工具,表示您已经安装了多个python版本。

For example, if you run 例如,如果您运行

pip2.7 install requests

It will install the "requests" package at /Library/Python/2.7/site-packages/, and you can use it like: 它将在/Library/Python/2.7/site-packages/中安装“ requests”包,您可以像这样使用它:

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

to clean and tidy up this mess, and uninstall all packages/programs I have previously installed that relates to pip, python, homebrew, nnpm 清理并整理此混乱情况,并卸载我以前安装的所有与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

I strongly suggest you not to install packages globally. 我强烈建议您不要全局安装软件包。

You should always use virtualenv to manage you python development environments. 您应该始终使用virtualenv来管理python开发环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM