title: Python Pip broken with sys.stderr.write(f"ERROR: {exc}")
body: <p>On fresh Vagrant VM using box bento/centos-7 the following commands corrupt my pip installation:</p>
  <pre><code>yum update
  yum install epel-release -y
  yum install python-pip -y
  /usr/bin/pip2 install --upgrade pip setuptools pyOpenSSL psycopg2-binary lxml
  </code></pre>
  <p>This fails at the end with</p>
  <pre><code>  Downloading https://files.pythonhosted.org/packages/84/48/5c99d8770fd0a9eb0f82654c3294aad6d0ba9f8600638c2e2ad74f2c5d52/setuptools-52.0.0.tar.gz (2.1MB)
      100% |████████████████████████████████| 2.1MB 821kB/s
      Complete output from command python setup.py egg_info:
      Traceback (most recent call last):
        File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
        File &quot;setuptools/__init__.py&quot;, line 16, in &lt;module&gt;
          import setuptools.version
        File &quot;setuptools/version.py&quot;, line 1, in &lt;module&gt;
          import pkg_resources
        File &quot;pkg_resources/__init__.py&quot;, line 1367
          raise SyntaxError(e) from e
                                  ^
      SyntaxError: invalid syntax
  
      ----------------------------------------
  Command &quot;python setup.py egg_info&quot; failed with error code 1 in /tmp/pip-build-GZrC3W/setuptools/
  You are using pip version 8.1.2, however version 21.0 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  </code></pre>
  <p>If I then upgrade Pip I notice that my Python is broken. After that all pip commands end with <code>SyntaxError</code></p>
  <pre><code>[root@bkd-openam ~]# pip install --upgrade pip
  Collecting pip
    Using cached https://files.pythonhosted.org/packages/9e/24/bc928987f35dd0167f21b13a1777c21b9c5917c9894cff93f1c1a6cb8f3b/pip-21.0.tar.gz
  Installing collected packages: pip
    Found existing installation: pip 8.1.2
      Uninstalling pip-8.1.2:
        Successfully uninstalled pip-8.1.2
    Running setup.py install for pip ... done
  Successfully installed pip-21.0
  [root@bkd-openam ~]# /usr/bin/pip2 install --upgrade pip setuptools pyOpenSSL psycopg2-binary lxml
  Traceback (most recent call last):
    File &quot;/usr/bin/pip2&quot;, line 9, in &lt;module&gt;
      load_entry_point('pip==21.0', 'console_scripts', 'pip2')()
    File &quot;/usr/lib/python2.7/site-packages/pkg_resources.py&quot;, line 378, in load_entry_point
      return get_distribution(dist).load_entry_point(group, name)
    File &quot;/usr/lib/python2.7/site-packages/pkg_resources.py&quot;, line 2566, in load_entry_point
      return ep.load()
    File &quot;/usr/lib/python2.7/site-packages/pkg_resources.py&quot;, line 2260, in load
      entry = __import__(self.module_name, globals(),globals(), ['__name__'])
    File &quot;/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py&quot;, line 60
      sys.stderr.write(f&quot;ERROR: {exc}&quot;)
                                     ^
  SyntaxError: invalid syntax
  </code></pre>
  <p>Why is this? Is this a known issue with Python? How do I fix this?</p>
  <p>BTW, CentOS 7 is a given, we cannot upgrade to CentOS 8 at this point. Also, we are using Ansible so using virtualenv I think for target nodes is recommended against by the Ansible community.</p>
  <p>We can install Python 3 of course on target nodes but not all Ansible code is available for combination Python 3 with CentOS 7.</p>
  <p>Can we use Pip 20?  We would like to upgrade to the most recent version of Pip that still works and I think that is Pip 20. How do I prevent upgrade to Pip 21?</p>