0

I'm running bitcoind/ bitcoind -regtest on Windows 10 and am already able to use bitcoin-cli -regtest along with json-rpc methods to perform basic operations and get balances etc. When I try to do this programmatically on python 3 using Jeff Garzik's python-bitcoinrpc package (https://github.com/jgarzik/python-bitcoinrpc) I get a modulenotfounderror. However, my pip3 freeze shows python-bitcoinlib==0.10.1 and also python-bitcoinrpc==1.0.

My code is below (18443 is the regtest port):

from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:18443"%("myrpcuser","myrpcpassword"))

best_block_hash = rpc_connection.getbestblockhash() print(rpc_connection.getblock(best_block_hash))

What am I doing wrong?

Separately, is there a way to make the json-rpc calls into bitcoind directly from python3 instead of using this library, since it seems really old and out of use? Very grateful for your kind help!

  • Are you sure your script is running with python3 an not python2? On many OS's, the default python is still python2. – Andrew Chow Mar 15 at 17:36
  • Yes sir, I downloaded and used python3. I installed the package using pip3 install python-bitcoinrpc. Is there something else I should be doing? Appreciate your help to a noob. – oktested Mar 16 at 3:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.