<p>I had named my script <code>bitcoinrpc.py</code> and had the import <code>bitcoinrpc</code>. Naturally it couldn't find the <code>package</code>. Renamed the script and it works.</p>
<p>Lesson: DO NOT have a file of the same name as the package you are trying to import.</p>

CC BY-SA 4.0
2020-06-19T02:01:39.783Z
2020-06-19T02:01:39.783Z
jodobear
<p>I am unable to import the package <code>bitcoinrpc</code>.</p>
<p>I have installed it in python2 and python3 using <code>python3 -m pip install python-bitcoinrpc</code>/<code>python -m pip install python-bitcoinrpc</code> AND by cloning the repo and editing the python environment in <code>setup.py</code> to my python2 and 3 path. Which returns <code>Requirement already satisfied: python-bitcoinrpc in /home/a/.local/lib/python3.6/site-packages (1.0)</code></p>
<p>Even after that I get the following errors:</p>
<p>Python2: <code>ImportError: No module named authproxy</code></p>
<p>Python3: <code>ModuleNotFoundError: No module named 'bitcoinrpc.authproxy'; 'bitcoinrpc' is not a package</code></p>
<p>Following is my code:</p>
<pre><code>from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_user = &quot;xxx&quot;
rpc_password = &quot;xxx&quot;
rpc_connection = AuthServiceProxy(&quot;http://%s:%s@127.0.0.1:8332&quot;%(rpc_user, rpc_password))

print(rpc_connection.get_info())
</code></pre>
<p>I have searched as much as I could but, cannot find anyting except for <a href="https://bitcoin.stackexchange.com/questions/85333/python-bitcoinrpc-modulenotfounderror-no-module-named-bitcoinrpc">this bitcoin stackexchange question</a> without an answer.</p>
<p>ENV: OS: Mint 19.1 with Anaconda where <code>which python(3)</code> return <code>/usr/bin/python(3)</code></p>
<p>Is the setup broken or am I missing something?</p>
<p>Any help is appreciated. Thank you!</p>

<json-rpc><python>
Cannot import python-bitcoinrpc
jodobear
# Cannot import python-bitcoinrpc

(Asked by: username_0 on 2020-06-15)

I am unable to import the package `bitcoinrpc`.

I have installed it in python2 and python3 using `python3 -m pip install python-bitcoinrpc`/`python -m pip install python-bitcoinrpc` AND by cloning the repo and editing the python environment in `setup.py` to my python2 and 3 path. Which returns `Requirement already satisfied: python-bitcoinrpc in /home/a/.local/lib/python3.6/site-packages (1.0)`

Even after that I get the following errors:

Python2: `ImportError: No module named authproxy`

Python3: `ModuleNotFoundError: No module named 'bitcoinrpc.authproxy'; 'bitcoinrpc' is not a package`

Following is my code:

```
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_user = "xxx"
rpc_password = "xxx"
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%(rpc_user, rpc_password))

print(rpc_connection.get_info())

```

I have searched as much as I could but, cannot find anyting except for [this bitcoin stackexchange question](https://bitcoin.stackexchange.com/questions/85333/python-bitcoinrpc-modulenotfounderror-no-module-named-bitcoinrpc) without an answer.

ENV: OS: Mint 19.1 with Anaconda where `which python(3)` return `/usr/bin/python(3)`

Is the setup broken or am I missing something?

Any help is appreciated. Thank you!

**Tags:** json-rpc, python


---

## 1 answers

### Answer by username_0 on 2020-06-19. Score: 1 | Accepted answer

I had named my script `bitcoinrpc.py` and had the import `bitcoinrpc`. Naturally it couldn't find the `package`. Renamed the script and it works.

Lesson: DO NOT have a file of the same name as the package you are trying to import.


---

