Python Pip broken with sys.stderr.write(f“ERROR: {exc}”) centos:7 [duplicate]

  centos, docker, pip, python, sympy

upgrade Pip I notice that my Python is broken. After that all pip commands end with SyntaxError

Below is my docker commands:

FROM centos:7
RUN yum clean all && yum -y update &&  yum install epel-release -y && yum install python-pip R 
libcurl-devel openssl-devel -y
RUN pip install --upgrade pip
RUN pip install sympy
WORKDIR /root/
COPY ./ agro-green/
WORKDIR /root/agro-green/
RUN Rscript build/install.R

Error as below:

Step 4/9 : RUN pip install --upgrade pip
Using cache
Step 5/9 : RUN pip install sympy
Running in c60ca73cc452
[91mTraceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==21.0.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/", line 2566, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/", line 2260, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/ma`enter code here`", line 60
sys.stderr.write(f"ERROR: {exc}")`enter code here`
                               ^`enter code here`
 SyntaxError: invalid syntax
 [0mThe command '/bin/sh -c pip install sympy' returned a non-zero code: 1
 Build step 'Execute shell' marked build as failure
 Finished: FAILURE` enter code here`

Source: Docker Questions