<p>First, install libssl-dev:</p>
<pre><code>sudo apt-get install libssl-dev
</code></pre>
<p>Install python3-pip if not yet:</p>
<pre><code>sudo apt install python3-pip
</code></pre>
<p>Lastly, install python-bitcoinlib:</p>
<pre><code>pip3 install python-bitcoinlib
</code></pre>
<p>In the example code, it is</p>
<pre><code>info = p.getinfo()
</code></pre>
<p>Ran the example, I got &quot;bitcoin.rpc.JSONRPCError: {'code': -32601, 'message': 'Method not found'}&quot;</p>
<p>Change it to:</p>
<pre><code>info = p.getblockchaininfo()
</code></pre>
<p>(see <a href="https://bitcoincore.org/en/doc/0.21.0/rpc/blockchain/getblockchaininfo/" rel="nofollow noreferrer">https://bitcoincore.org/en/doc/0.21.0/rpc/blockchain/getblockchaininfo/</a>)</p>
<p>It works fine. I got the total number of blocks. In my case, it is 682903.</p>

CC BY-SA 4.0
2021-05-10T16:44:43.977Z
2021-05-10T16:54:31.200Z
2021-05-10T16:54:31.200Z
Yong Yu
<p>bicoinlib is the module you try to use to handle bitcoind, bitcoin-cli in python,  rpc module is part of bitcoinlib.</p>

<p>libssl-dev is needed to handle SSL and TLS cryptographic protocols . </p>

<p>if bitcoinlib not work in newer bitcoin core versions 0.15 or newer just use raw bitcoinrpc.authProxy module.</p>

CC BY-SA 3.0
2017-09-26T03:57:37.517Z
2017-09-26T03:57:37.517Z
Guillermo Graña
<p>in debian =) </p>

<p>sudo apt-get install libssl-dev</p>

<p>pip install python-bitcoinlib 
 or 
pip3 install python-bitcoinlib</p>

CC BY-SA 3.0
2017-09-25T19:57:51.600Z
Thank you. That worked. Can I ask how you knew this? there seems to be no association to the library name in `import` and what you install. I looked everywhere online trying to figure out the library.
user2242044
CC BY-SA 3.0
2017-09-25T19:15:29.007Z
2017-09-25T19:15:29.007Z
Guillermo Graña
<p>I am working through Master Bitcoin. I got the <code>bitcoin client</code> up and running. I am now trying to access the client from <code>python</code>. In the example, there is a line that says <code>from bitcoin.rpc import Rawproxy</code>. </p>

<p>I get the error message <code>no module named rpc</code>. When I run <code>pip freeze</code>, I have <code>python-bitcoinrpc==1.0</code> listed. Why can't this module be found?</p>

<bitcoin-core><client><python><bitcoin-cli>
bitcoin.rpc python library problem
user2242044
# bitcoin.rpc python library problem

(Asked by: username_0 on 2017-09-25)

I am working through Master Bitcoin. I got the `bitcoin client` up and running. I am now trying to access the client from `python`. In the example, there is a line that says `from bitcoin.rpc import Rawproxy`.

I get the error message `no module named rpc`. When I run `pip freeze`, I have `python-bitcoinrpc==1.0` listed. Why can't this module be found?

**Tags:** bitcoin-core, client, python, bitcoin-cli


---

## 3 answers

### Answer by username_2 on 2017-09-25. Score: 7 | Accepted answer

in debian =)

sudo apt-get install libssl-dev

pip install python-bitcoinlib
or
pip3 install python-bitcoinlib

> **Comments:**
> **username_0**: Thank you. That worked. Can I ask how you knew this? there seems to be no association to the library name in `import` and what you install. I looked everywhere online trying to figure out the library.  

---

### Answer by username_1 on 2021-05-10. Score: 0

First, install libssl-dev:

```
sudo apt-get install libssl-dev

```

Install python3-pip if not yet:

```
sudo apt install python3-pip

```

Lastly, install python-bitcoinlib:

```
pip3 install python-bitcoinlib

```

In the example code, it is

```
info = p.getinfo()

```

Ran the example, I got "bitcoin.rpc.JSONRPCError: {'code': -32601, 'message': 'Method not found'}"

Change it to:

```
info = p.getblockchaininfo()

```

(see <https://bitcoincore.org/en/doc/0.21.0/rpc/blockchain/getblockchaininfo/>)

It works fine. I got the total number of blocks. In my case, it is 682903.


---

### Answer by username_2 on 2017-09-26. Score: 0

bicoinlib is the module you try to use to handle bitcoind, bitcoin-cli in python, rpc module is part of bitcoinlib.

libssl-dev is needed to handle SSL and TLS cryptographic protocols .

if bitcoinlib not work in newer bitcoin core versions 0.15 or newer just use raw bitcoinrpc.authProxy module.


---

