Michael
Michael

Reputation: 33297

Pip upgrade failed with ERROR: Invalid requirement: '\xe2\x80\x93upgrade'

I tried to upgrade pip with:

pip install –upgrade setuptools pip wheel

and got the following error:

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

ERROR: Invalid requirement: '\xe2\x80\x93upgrade'

After doing:

sudo pip install --upgrade setuptools pip wheel

I get the following error:

ERROR: Could not install packages due to an EnvironmentError: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/private/tmp/pip-uninstall-MzJySA/markers.pyc', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-MzJySA/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py', '/private/tmp/pip-uninstall-MzJySA/init.py', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-MzJySA/init.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/private/tmp/pip-uninstall-MzJySA/markers.py', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-MzJySA/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc', '/private/tmp/pip-uninstall-MzJySA/init.pyc', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-MzJySA/init.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/private/tmp/pip-uninstall-MzJySA', "[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-MzJySA'")]

How can I fix that on OSX?

Upvotes: 7

Views: 20351

Answers (2)

tripleee
tripleee

Reputation: 189397

\xe2\x80\x93 is the UTF-8 encoding of the Unicode character EN DASH U+2013 which is entirely distinct from (though vaguely visually similar to) the double ASCII minus character which commonly indicates an option name.

You want --upgrade, not –upgrade.

Sometimes e.g. blog platforms "helpfully" replace ASCII sequences like dashes, quotes, etc with "typographic" HTML equivalents which are more pleasing to the eye, but such substitutions should never be performed in code spans.

On MacOS, I would seriously caution against trying to upgrade the system-supplied files; sometimes, they are pinned to an older version for very good reasons, and regardless of that, you will be jeopardizing your ability to install future OS upgrades correctly if you muck with system files. Instead, try to use an isolated environment where you can upgrade individual libraries without touching the ones supplied by the system - the venv package installed with Python 3 is the baseline solution, but there are alternatives like the third-party virtualenv package (if you are really still stuck on Python 2! With condolences), pyenv, miniconda etc.

Upvotes: 6

razimbres
razimbres

Reputation: 5015

Try running:

pip install --upgrade setuptools pip wheel

With double --

Upvotes: 4

Related Questions