One of the above answer provides the solution:
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales
The problem with above solution is that it has to be done on the linux shell. However, if you are providing your code to work on the client machine then this is a bad approach. I also tried executing the above commands using os.system(), but still it doesn't work.
Solution that worked for me is
locale.setlocale(locale.LC_ALL,'en_US.UTF-8')