api – Bitcoind python connection

0
63


I am making an attempt to hook up with bitcoind with python3. I am presently following the directions of Antonopolous ebook.

That is my code on an IDE:

from bitcoin.rpc import RawProxy
p = RawProxy()
data = p.getinfo()
print(data['blocks'])

Sadly I solely get warnings:

/residence/pariya/python_pr/venv/bin/python /residence/pariya/python_pr/essential.py 
Traceback (most up-to-date name final):
  File "/residence/pariya/python_pr/venv/lib/python3.10/site-packages/bitcoin/rpc.py", line 190, in __init__
    with open(cookie_file, 'r') as fd:
FileNotFoundError: [Errno 2] No such file or listing: '/residence/pariya/.bitcoin/.cookie'

Throughout dealing with of the above exception, one other exception occurred:

Traceback (most up-to-date name final):
  File "/residence/pariya/python_pr/essential.py", line 5, in <module>
    p = RawProxy()
  File "/residence/pariya/python_pr/venv/lib/python3.10/site-packages/bitcoin/rpc.py", line 313, in __init__
    tremendous(RawProxy, self).__init__(service_url=service_url,
  File "/residence/pariya/python_pr/venv/lib/python3.10/site-packages/bitcoin/rpc.py", line 197, in __init__
    increase ValueError('Cookie file unusable (%s) and rpcpassword not specified within the configuration file: %r' % (err, btc_conf_file))
ValueError: Cookie file unusable ([Errno 2] No such file or listing: '/residence/pariya/.bitcoin/.cookie') and rpcpassword not specified within the configuration file: '/residence/pariya/.bitcoin/bitcoin.conf'

Course of completed with exit code 1

I am operating bitcoind on an exterior laborious drive. Is one thing lacking in my code?

Grateful for any assist.

LEAVE A REPLY

Please enter your comment!
Please enter your name here