0

When I try to install anything via pip, I get this error. How to fix it?

 % pip install --upgrade pip
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, 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 489, 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 2843, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2434, in load
    return self.resolve()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2440, 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
Ruchit Patel
  • 733
  • 1
  • 11
  • 26
  • 1
    The version of python your system is finding doesn't correspond to the version of pip. How did you install pip and python? Is your PATH set correctly? – BallpointBen Jan 31 '21 at 04:41
  • Looks like some environment error. (and you're using Mac, I guess?) A possible workaround is to uninstall and reinstall everything; but it's almost impossible to give a more targeted way because there is only a little info on your environment. – user202729 Jan 31 '21 at 04:43
  • @user202729, yes, I run it on mac, and I really want to do what you suggested, just reinstall everything. But I don't know how to do it. Right now I'm not able to install anything using pip, this is happening after I updated my mac last night. – Ruchit Patel Jan 31 '21 at 04:45
  • @BallpointBen, afaik, I did not install python. For pip, I think i used some python command to do it, but I don;t fully remember exactly how I installed pip. I can give you more details if you tell me what I should provide. – Ruchit Patel Jan 31 '21 at 04:47
  • Because pip is broken you would need to do it in Mac (how did you install Python and in the first place?) – user202729 Jan 31 '21 at 04:47
  • Well surely you can find some documentation to install Python on Mac... – user202729 Jan 31 '21 at 04:47
  • @user202729, Can I remove python from `Library/python` ? Is it safe to remove entire directory? – Ruchit Patel Jan 31 '21 at 05:42
  • Perhaps [macos - How to fix broken python 2.7.11 after OSx updates - Stack Overflow](https://stackoverflow.com/questions/34303294/how-to-fix-broken-python-2-7-11-after-osx-updates)? – user202729 Jan 31 '21 at 06:32

0 Answers0