No module name 'xmlrpclib' when using Electrum from Command line
Asked Answered
S

1

8

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.

Sharp answered 3/5, 2017 at 2:46 Comment(0)
A
16

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.

Alecto answered 3/5, 2017 at 2:56 Comment(2)
"no module named client"Sharp
thank you for that. i no longer get that ImportError, however im getting a different one and the answer isnt as simple as the one you just gave me.. the httplib library also changed to http.client... so i made that necessary change but now im getting a cannot import name 'HTTP' in the line from http.client import HTTP, HTTPConnectionSharp

© 2022 - 2024 — McMap. All rights reserved.