jgarzik / python-bitcoinrpc

Python interface to bitcoin's JSON-RPC API
GNU Lesser General Public License v2.1
642 stars 307 forks source link

[SOLVED] Cannot import python-bitcoinrpc #100

Closed jodobear closed 4 years ago

jodobear commented 4 years ago

I am unable to import the package bitcoinrpc.

I have installed it in python2 and python3 using python3 -m pip python-bitcoinrpc/python -m pip python-bitcoinrpc AND by cloning the repo and editing the python environment in setup.py to my python2 and 3 path. 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 without an answer.

Is the setup broken or am I missing something?

Any help is appreciated. Thank you!

matmaer commented 4 years ago

You are probably missing something. Check the PATH variable for example.

jodobear commented 4 years ago

Thank you!

Do you mean in the setup.py? It is either #!/usr/bin/python or #!/usr/bin/python3

Output of $ which python > /usr/bin/python and for $ which python3 > /usr/bin/python3

I also do have anaconda installed. Could that be messing about? But, I don't think that should be an issue since, output of which python ..

jodobear commented 4 years ago

[RESOLVED]:

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

Learnt my lesson.