python-bitcoinlib
                                
                                 python-bitcoinlib copied to clipboard
                                
                                    python-bitcoinlib copied to clipboard
                            
                            
                            
                        Error: File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None
Got this program:
import bitcoin.rpc
proxy_connection = bitcoin.rpc.RawProxy(service_url='http://127.0.0.1', service_port=44555)
print(proxy_connection.getnewaddress())
When I'm trying to execute it got error:
Traceback (most recent call last):
  File "electrum_to_clam.py", line 5, in <module>
    print(proxy_connection.getnewaddress())
  File "/usr/local/lib/python3.4/dist-packages/bitcoin/rpc.py", line 244, in <lambda>
    f = lambda *args: self._call(name, *args)
  File "/usr/local/lib/python3.4/dist-packages/bitcoin/rpc.py", line 186, in _call
    response = self._get_response()
  File "/usr/local/lib/python3.4/dist-packages/bitcoin/rpc.py", line 213, in _get_response
    parse_float=decimal.Decimal)
  File "/usr/lib/python3.4/json/__init__.py", line 331, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 2 column 1 (char 1)
What may be the reason?
Weird.
What version of Bitcoin Core are you running?
0.11.1
Huh, sorry, I can't seem to reproduce that here.
What's your bitcoin.conf? That's a non-standard service port.
Put a Python pdb breakpoint to the line before it raise ValueError. Inspect the content of s variable to see what it is trying to decode.
https://www.youtube.com/watch?v=bZZTeKPRSLQ
I've got similar problem. This is example code from "Mastering Bitcoin":
from bitcoin.rpc import RawProxy
# Create a connection to local Bitcoin Core node
p = RawProxy()
# Run the getinfo command, store the resulting data in info
info = p.getinfo()
	
# Retrieve the 'blocks' element from the info
print(info['blocks'])
This is the error I get:
$ python3 rpc_example.py 
Traceback (most recent call last):
  File "rpc_example.py", line 8, in <module>
    info = p.getinfo()
  File "/usr/local/lib/python3.4/dist-packages/bitcoin/rpc.py", line 268, in <lambda>
    f = lambda *args: self._call(name, *args)
  File "/usr/local/lib/python3.4/dist-packages/bitcoin/rpc.py", line 209, in _call
    response = self._get_response()
  File "/usr/local/lib/python3.4/dist-packages/bitcoin/rpc.py", line 236, in _get_response
    parse_float=decimal.Decimal)
  File "/usr/lib/python3.4/json/__init__.py", line 331, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)
v0.14.2
@Serasar @miohtama @NewCryptoWorld @petertodd Found the issue (on my side) I see the error described above with the wrong RPC password.
This appears in my bitcoin.log 2017-11-23 12:33:54 ThreadRPCServer incorrect password attempt from [::1]:36762
and response from Proxy().getblockcount() is b'' (empty)
I'd suggest putting in an error for "Incorrect Password"