That log file suggests that apt was already being used when it tried to install pip:
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
sudo: pip3: command not found
The script should retry, or fail, if that happens, rather than continuing with a broken system.
@borpin Is there a reason not to install python modules to the system path?