<p>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 (<a href="https://github.com/jgarzik/python-bitcoinrpc" rel="nofollow noreferrer">https://github.com/jgarzik/python-bitcoinrpc</a>) I get a modulenotfounderror. However, my pip3 freeze shows python-bitcoinlib==0.10.1 and also python-bitcoinrpc==1.0.</p>

<p>My code is below (18443 is the regtest port):</p>

<blockquote>
  <p>from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException</p>
  
  <p>rpc_connection = AuthServiceProxy("<a href="http://%s:%s@127.0.0.1:18443" rel="nofollow noreferrer">http://%s:%s@127.0.0.1:18443</a>"%("myrpcuser","myrpcpassword")) </p>
  
  <p>best_block_hash = rpc_connection.getbestblockhash()
  print(rpc_connection.getblock(best_block_hash))</p>
</blockquote>

<p>What am I doing wrong?</p>

<p>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!</p>

CC BY-SA 4.0
2019-03-15T17:36:05.660Z
Are you sure your script is running with python3 an not python2? On many OS's, the default python is still python2.
Ava Chow
CC BY-SA 4.0
2019-03-16T03:52:44.160Z
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
<bitcoin-core><json-rpc><python>
python-bitcoinrpc: modulenotfounderror no module named 'bitcoinrpc'
oktested
# python-bitcoinrpc: modulenotfounderror no module named 'bitcoinrpc'

(Asked by: username_0 on 2019-03-15)

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!

**Tags:** bitcoin-core, json-rpc, python

> **Comments:**
> **username_1**: Are you sure your script is running with python3 an not python2? On many OS's, the default python is still python2.  
> **username_0**: 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.  

---

## 0 answers

