Bitcoin Forum
May 10, 2024, 06:28:01 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: python-bitcoinrpc: modulenotfounderror no module named 'bitcoinrpc'  (Read 238 times)
rajalaxmi (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 2


View Profile
March 15, 2019, 09:03:55 AM
Merited by LoyceV (1), ABCbits (1)
 #1

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?
The block chain is the main innovation of Bitcoin. It is the first distributed timestamping system.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715322481
Hero Member
*
Offline Offline

Posts: 1715322481

View Profile Personal Message (Offline)

Ignore
1715322481
Reply with quote  #2

1715322481
Report to moderator
1715322481
Hero Member
*
Offline Offline

Posts: 1715322481

View Profile Personal Message (Offline)

Ignore
1715322481
Reply with quote  #2

1715322481
Report to moderator
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
March 15, 2019, 09:53:17 AM
 #2

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.
What am I doing wrong?

Well... according to the install instructions on github... it looks like this might be Python 2 only...
change the first line of setup.py to point to the directory of your installation of python 2.*

Have you tried it with a Python 2.7 install? Huh

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
rajalaxmi (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 2


View Profile
March 15, 2019, 10:28:54 AM
 #3

Thank you for your reply. Afraid I haven't tried with python 2.7. I'm new to python and have spent quite a lot of time making stuff with python 3 so I would like to avoid moving to python 2 now. Would you happen to know any other way in which I can make the json-rpc calls to bitcoind from python 3? Appreciate your help.
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
March 15, 2019, 11:25:42 AM
 #4

Actually it should also work with python3.

Python can be quite cocky with the 'Module not found' errors.
You might have to adjust the path to get it working.

But syntactically there is not a lot of difference between python3 and python2. Those are just minimal.
If you are familiar with python3, you will easily be able to get your code working in python2.


Your only 2 options are to either get it working via adjusting paths / making changes to the package or using python2.

rajalaxmi (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 2


View Profile
March 15, 2019, 11:58:54 AM
 #5

Thanksfor your reply! How/ where do I adjust the path, please? I installed the package directly using "pip3 install python-bitcoinrpc". And then I tried importing it from within my python script (I use spyder IDE). Sorry for the noob question but where should I be adjusting paths and what should the new path be, please?
rajalaxmi (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 2


View Profile
March 16, 2019, 03:59:28 AM
 #6

Is there a video tutorial on Youtube/elsewhere on how to make json-rpc calls from python, or to use this python-bitcoinrpc library? The instructions are very sparse on the github page and I'm keen to learn this. I'm sure many people are as keen as I am, but I can't find any such video.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!