2

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:%[email protected]: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 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!

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.