3

I want to clean up my installations on my MacBook Pro at the moment. In the past, I have installed things like homebrew, pip, python, nnpm and some other things that I don't even remember.

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. Looking around stackoverflow, I tried to change some permissions of the files and folders involved:

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:

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 (e.g. pip -V now give about the same error.

Now, I check /usr/local/bin and see a huge mess of files. To give you an idea: ls /usr/local/bin returns

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.

.

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. 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.

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.

Shawn
  • 185
  • 1
  • 2
  • 7
  • Have you tried https://stackoverflow.com/questions/38753907/importerror-entry-point-console-scripts-pip-not-found-on-mac to fix your problem ? – Matthias Beaupère Apr 25 '19 at 09:28
  • 1
    Python is an interpreter for the python language, pip is a package manager for python, homebrew is a more general application manage for mac – Matthias Beaupère Apr 25 '19 at 09:31

1 Answers1

3

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.

npm is a package management tool for nodejs, it behaves like pip for python, cpan for perl

pip(pip2, pip2.x, pip3, pip3.x) is a package management tool for python, has no relationship with homebrew.

The suffix after "pip" indicates which python version it manages. You saw several pip tool, indicates you have installed several python versions.

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:

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

# 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.

饶伟健
  • 46
  • 2
  • It seems like I did not install python via homebrew. ```brew list``` returns: ```chromedriver icu4c node``` only, without python – Shawn Apr 25 '19 at 11:20
  • You can ignore the uninstall step.Just remove the /Library/Python directory and reinstall python will fix your problems. – 饶伟健 Apr 25 '19 at 12:24