Example fails with Python 3.6.6
Due to the split of urllib2 into parts (urllib.error, urllib.parse, urllib.request) the library cannot be used with python 3.6.6.
Once the client code updated to urllib another problem occurs: ../python3.6/site-packages/eureka_client/requests.py", line 46, in create response = request.opener.open(request) File "/usr/lib/python3.6/urllib/request.py", line 524, in open req = meth(req) File "/usr/lib/python3.6/urllib/request.py", line 1248, in do_request raise TypeError(msg) TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
On SO recommend to encode url into utf-8: data = urllib.parse.urlencode(data) data = data.encode('utf-8')
But then another error follows: ..lib/python3.6/site-packages/eureka_client/requests.py", line 42, in create data = urllib.parse.urlencode(data) # I added this File "/usr/lib/python3.6/urllib/parse.py", line 864, in urlencode "or mapping object").with_traceback(tb) File "/usr/lib/python3.6/urllib/parse.py", line 856, in urlencode raise TypeError TypeError: not a valid non-string sequence or mapping object
How to fix it?
also looks like installation for the client could be improved: dependencies are not communicated to pip, as a result one has to install missing libraries one by one while fixing missing packages errors
also looks like used package ec2metadata interface has been changed, python complains about missing get method in ec2metadata. This error happens if datacenter is not specified or Amazon (the default option).