0

So I've been trying to get "pip" to work with the python installation on my osx laptop (Mojave), and I seem to have ended up with a bugged pip installation where I can't use any of the pip commands and ofc most importantly the uninstall command. Every time I try to use pip I end up with this error message:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==21.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 2697, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
    return self.resolve()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Python/2.7/site-packages/pip-21.0.1-py2.7.egg/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

I had a look into the /usr folder to see if I can manually delete the files but I don't think it's a good idea to mess with things like that especially with the knowledge I have xP any help would be very much appreciated!

dtanabe
  • 1,611
  • 9
  • 18
Yashpashar
  • 31
  • 1
  • 9
  • We can't tell what you broke or how you broke it. Did you try to install Python 3? Diid you upgrade the system `pip` to a version which is no longer compatible with the system `python` 2.7? The existence of `/usr/local/bin/pip` suggests that you have a custom install from somewhere, but how did that end up there? – tripleee Feb 02 '21 at 14:33
  • I had a version of python 3 I deleted it and reinstalled 3.9.1 from the website. I haven't really done anything python related for a while so I genuinely do no remember any of my previous attempts to get pip to works from years ago... that's why I'm just trying to delete everything and have a totally fresh install – Yashpashar Feb 02 '21 at 14:47

1 Answers1

0

The easiest solution would probably just be to completely uninstall python from your computer and then re-download from python.org. If you download from the python website, it automatically comes with pip installed for the mac.

This shows how to uninstall: https://www.macupdate.com/app/mac/5880/python/uninstall

Then, just go to python.org and reinstall

Samantha Garcia
  • 490
  • 6
  • 13
  • I Uninstalled python as a whole but the command "pip" still gives out the same error as before even though I haven't reinstalled python. I also had trouble with the third step of the Guide since the first step of method2 comes up with no results – Yashpashar Feb 02 '21 at 14:57
  • According to this link you can try: You could download https://bootstrap.pypa.io/get-pip.py and run python get-pip.py --ignore-installed to reinstall pip. https://github.com/pypa/pip/issues/1892 – Samantha Garcia Feb 02 '21 at 15:04
  • Sorry for the stupid question but how do I download the .py file off the link? – Yashpashar Feb 02 '21 at 15:15
  • not a stupid question. You can type this into command line directly: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py – Samantha Garcia Feb 02 '21 at 15:23
  • Once I paste that into terminal just shows the UI type download interface and then goes to the next line. all the numbers for speed stay at zero and the percentage downloaded fields are empty :( – Yashpashar Feb 02 '21 at 15:30
  • that's normal. Now put in the line python get-pip.py --ignore-installed – Samantha Garcia Feb 02 '21 at 15:41
  • you probably need to reinstall python first, though – Samantha Garcia Feb 02 '21 at 15:41
  • In any case, if you go to this folder on your computer: /Library/Python/2.7/site-packages/ you can just delete the pip folder. It shouldn't mess anything up since you want to delete pip. – Samantha Garcia Feb 02 '21 at 15:44
  • 1
    Ended up just deleting everything in the local/bin folder! Was the only thing that fixed the issue. Thanks a lot for the help :D – Yashpashar Feb 03 '21 at 04:58