Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module name 'xmlrpclib' when using Electrum from Command line

I just installed a bitcoin wallet from command line from Electrum.org

heres how i installed it in my user account directory .. /home/user/...

sudo pip3 install https://download.electrum.org/2.8.2/Electrum-2.8.2.tar.gz

and it installed with no issues.

When i attempt to run the software from command line using electrum or if i try electrum help i get this ImportError

(heres their documentation http://docs.electrum.org/en/latest/cmdline.html)

ImportError: No module named 'xmlrpclib'

heres the traceback if you are trying to replicate it

File "/usr/local/bin/electrum", line 71, in check_imports
import jsonrpclib

File "/usr/local/lib/python3.5/dist-packages/jsonrpclib/__init__.py", line 5, in <module>
from jsonrpclib.jsonrpc import Server, MultiCall, Fault

File "/usr/local/lib/python3.5/dist-packages/jsonrpclib/jsonrpc.py", line 50, in <module> 
from xmlrpclib import Transport as XMLTrasnport

I have done

sudo apt-get update

sudo apt-get upgrade

sudo pip install xmlrpclib

but have had no avail.

If anyone can provide some insight thatd be greatly appreciated.

like image 369
Benji Weiss Avatar asked May 03 '17 02:05

Benji Weiss


1 Answers

The xmlrpclib module has been renamed to xmlrpc.client in Python 3.

So, if you want to use xmlrpclib

import xmlrpclib

Replace that with this:

from xmlrpc import client

This project has not been updated for two years, so you can find this file /usr/local/lib/python3.5/dist-packages/jsonrpclib/jsonrpc.py and change

from xmlrpclib import Transport as XMLTransport
from xmlrpclib import SafeTransport as XMLSafeTransport
from xmlrpclib import ServerProxy as XMLServerProxy
from xmlrpclib import _Method as XML_Method

to

from xmlrpc.client import Transport as XMLTransport
from xmlrpc.client import SafeTransport as XMLSafeTransport
from xmlrpc.client import ServerProxy as XMLServerProxy
from xmlrpc.client import _Method as XML_Method 

Also you can use 2to3 to convert the source:

2to3 -w jsonrpc.py

Then change

line 168 from http.client import HTTP, HTTPConnection
line 186     class UnixHTTP(HTTP):

To

line 168 from http.client import HTTPConnection
line 186     class UnixHTTP(HTTPConnection):

Hope this helps.

like image 190
McGrady Avatar answered Nov 08 '22 05:11

McGrady