Original how to is here: https://gist.github.com/jacoblyles/80898d6388880334f3e5a78785702ccc
The following is updated for Ubuntu 18.04 as commented in above link.
Thanks heaps for this how-to. Here's an updated version that worked from me at the time of writing this comment. Cheers
Do the following steps on your freshly installed online Ubuntu 18.04 virtual machine (I tested this procedure on a fresh install. If you’ve already installed some of the dependencies on this machine, this procedure probably won’t work, because ubuntu won't download already installed packages, so use a fresh install.)
# 1) temporarily move existing debs (not required if no *.deb files exist)
mkdir /var/cache/apt/archives/tmp
mv /var/cache/apt/archives/*.deb /var/cache/apt/archives/tmp
# 2) install the dependencies
sudo apt-get install python3-pyqt5 python3-pip qrencode -y
# 3) grab the dependencies
cd /var/cache/apt/archives/
tar cfvz ~/debs.tar.gz *.deb
# 4) restore the pre-existing debs (not required if skipped step 1)
mv /var/cache/apt/archives/tmp/* /var/cache/apt/archives
rm -rf /var/cache/apt/archives/tmp
cd ~
mkdir python_libs
cd python_libs
sudo pip3 download https://download.electrum.org/3.1.3/Electrum-3.1.3.tar.gz
cd ~
tar cfvz ~/python_libs.tar.gz python_libs
cd ~
cp debs.tar.gz python_libs.tar.gz /media/<username>/<usblabel>
cd ~
mkdir debs
cd debs
cp /media/<username>/<usblabel>/debs.tar.gz .
tar xvfz debs.tar.gz
sudo dpkg -i *.deb
cd ~
cp /media/<username>/<usblabel>/python_libs.tar.gz ~/
tar xfvz python_libs.tar.gz
cd python_libs
sudo pip3 install --no-index --find-links=. Electrum-3.1.3.tar.gz
electrum