remove the pip and reinstall it, on ubantu16.04
sudo apt-get remove --purge python-pip sudo apt-get autoremove rm -r /home/xxx/.local/bin/pip rm -r /usr/local/bin/pip sudo apt update curl https://bootstrap.pypa.io/2.7/get-pip.py | sudo python sudo ln /usr/local/bin/pip /home/xxx/.local/bin/pip
https://stackoverflow.com/questions/65896334/python-pip-broken-with-sys-stderr-writeferror-exc
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwia1PWwxsvvAhVyxYsBHbquAFwQFjABegQIBxAD&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F65896334%2Fpython-pip-broken-with-sys-stderr-writeferror-exc&usg=AOvVaw0vseoneyWMkgQ9iK2S4EvH