Bitcoin electrum wallet install from source code

Introduction

In this tutorial, we are going to install all electrum dependencies from scratch. If you were having problem install python 3.7 and pyqt, here are the steps to install all required dependencies.

Step 1: Compile python 3.7

Download the following required packages:

apt install libffi-dev libbz2-dev liblzma-dev libsqlite3-dev libncurses5-dev libgdbm-dev zlib1g-dev libreadline-dev libssl-dev tk-dev build-essential libncursesw5-dev libc6-dev openssl git

Download the source code:

wget https://github.com/python/cpython/releases/tag/v3.7.2
cd cpython-3.7.2
./configure --prefix=$HOME/.local --enable-optimizations
make
make install

Since we use the prefix $HOME/.local, update you path to find python 3.7:

export PATH=$HOME/.local/bin/:$PATH

Step 2: Install PyQT5

Before compiling pyQT5 we need to compile sid:

Download it from:

wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.13/sip-4.19.13.tar.gz

Un tar the file and start the compilation:

tar xf sip-4.19.13.tar.gz
cd sip-4.19.13/
python3.7 configure.py --sip-module=PyQt5.sip
make
sudo make install

Now we are ready to compile PyQT5, download the source code from:

wget https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.11.3/PyQt5_gpl-5.11.3.tar.gz
tar xf PyQt5_gpl-5.11.3.tar.gz
cd PyQt5_gpl-5.11.3
python3.7 configure.py  --qmake=/usr/bin/qmake-qt5 --verbose
make
sudo make install # if you are using virtual env don’t use sudo!

Now we are ready to download electrum source code.

Step 3: Install electrum wallet from source code

First, we need to clone the code from GitHub repository and then switch to the latest tag (currently at 3.3.3).

git clone https://github.com/spesmilo/electrum.git
git checkout 3.3.3

Now execute the install script

pythonn3.7 setup.py install

try to execute run_electrum.

If you have any problems, please leave a comment!

Appendix: error

./run_electrum SyntaxError: invalid syntax

If you get the following error while running electrum it means you need a newer python version (at least 3.7):

File "./run_electrum", line 53
    sys.exit(f"Error: {str(e)}. Try 'sudo python3 -m pip install <module-name>'")
SyntaxError: invalid syntax

Error: No module named 'dns'.

You need to install dnspython package, try the following steps:

git clone https://github.com/rthalley/dnspython 
cd dnspython/ 
python3.7 setup.py install