[Solved] R4R pip3 failing - cannot fix werkzeug security alert

The DI RemoteCameraRobot project lists werkzeug 0.14.1 as a requirement, about which Git just sent a “Security Alert” suggesting version 0.15.3.

GitHub_Security_Alert

I checked python (2.7) and it shows

Python 2.7.13 (default, Sep 26 2018, 18:42:22) 
...
>>> import werkzeug
>>> print werkzeug.__version__
0.15.4
>>> 

but python3 shows the old version:

Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
...
>>> import werkzeug
>>> print(werkzeug.__version__)
0.14.1
>>> 

I cannot upgrade the python3 module because my pip3 seems to be broken:

pip3 freeze
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3126, in <module>
    @_call_aside
...
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 784, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==19.1.1' distribution was not found and is required by the application

Any ideas how to fix?

I don’t know if the following was the right thing to do, but I am not getting any exceptions now:

sudo apt-get remove python3-pip
sudo apt-get purge python3-pip
sudo apt autoremove

sudo mv /usr/local/bin/pip3 /usr/local/bin/pip3.old
sudo cp /usr/local/bin/pip3.5 /usr/local/bin/pip3

sudo apt-get install python3-pip

sudo pip3 install --upgrade Werkzeug

Installing collected packages: Werkzeug
  Found existing installation: Werkzeug 0.14.1
    Uninstalling Werkzeug-0.14.1:
      Successfully uninstalled Werkzeug-0.14.1
Successfully installed Werkzeug-0.15.5
WARNING: You are using pip version 19.1.1, however version 19.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

sudo pip3 install --upgrade pip

pip3 --version
   pip 19.2.2 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5) 

I checked that RemoteCameraRobot still runs properly with upgraded Werkzeug:

python3 remote_robot.py

no problems.