Title: [Python-BitcoinRPC] No module AuthProxy Post by: Nontenda on April 24, 2013, 11:22:00 AM Hello,
I'm trying to use the python library from jgarzik, https://github.com/jgarzik/python-bitcoinrpc I've downloaded and run a python setup.py build / install but I cannot import authproxy. It said that "no module name 'authproxy'" has been found. What did I do wrong ? All I did is to run setup.py from the lastest source on github. Is there anything more to do ? (using CPython on Windows) Thank you very much, EDIT : Pip freeze shows : C:\Python33\Scripts>pip freeze distribute==0.6.36 python-bitcoinrpc==0.1 EDIT 2 FOUND : Correct code is : import bitcoinrpc.authproxy import pprint BITCOINRPC = 'http://user:pass@127.0.0.1:8332/' pp = pprint.PrettyPrinter(indent=4) bitcoin = bitcoinrpc.authproxy.AuthServiceProxy(BITCOINRPC) data = bitcoin.getinfo() # call bitcoin 'getinfo' RPC But not working on Windows, don't know why. I'll try with PHP Title: Re: [Python-BitcoinRPC] No module AuthProxy Post by: jj30 on January 28, 2014, 04:40:51 AM This seems a good place to put a "hello world." I had a difficult time getting bitcoinrpc to work. Then I went to bitcoinJ, the Java one. WHOOAA BOY. Came runnin' right back.
So there is some confusion about jsonrpc vs. bitcoinrpc. Seems like jsonrpc is now for backwards-compatiblity. (There is even some forward compatibility, from what I've heard, but I don't know if it's true.) So follow the instructions on https://github.com/jgarzik/python-bitcoinrpc His instructions are sparse. You 'git clone http://above bitcoinrpc' and it will put all the files in a folder called bitcoinrpc. Then you 'python setup.py build' and then 'python setup.py install' Ok, so now you have to be running the daemon. Something like bitcoind -server -rpcpassword=<password> -rpcuser=<username> -port=8332 Then you are ready for hello world. Run python and in the shell you >>>import bitcoinrpc >>>import jsonrpc >>>b = jsonrpc.ServiceProxy("http://username:password@localhost:8332") >>>balance = b.float(b.getbalance()) >>>balance Decimal('0.00120000') >>> Yay! Title: Re: [Python-BitcoinRPC] No module AuthProxy Post by: jj30 on January 29, 2014, 12:29:06 AM Also get rid of everything on your machine that isn't python-bitcoinrpc-master. On windows, these are in your Python27\Lib\site-packages folder. You should be left with a bitcoinrpc folder and a python_bitcoinrpc-0.1-py2.7.egg-info. Use this documentation: https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29#Python
Here is some sample code: Code: import wx from bitcoinrpc.authproxy import AuthServiceProxy class MainWindow(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'HW', size = (600, 400)) panel = wx.Panel(self) sendbtc = wx.Button(panel, -1, "Send BTC", (80, 80)) self.Bind(wx.EVT_BUTTON, self.send_btc, sendbtc) wx.Frame.CenterOnScreen(self) pass def send_btc(one, two): # one is of type wxFrame # two is of type wxCommandEvent # send the bitcoins now h = AuthServiceProxy("http://<username>:<password>@localhost:8332") h.sendfrom('', '<bitcoinaddress>', 0.00110000) pass if __name__ == '__main__': app = wx.PySimpleApp() frame = MainWindow(parent = None,id = -1) frame.Show() app.MainLoop() Title: Re: [Python-BitcoinRPC] No module AuthProxy Post by: deepceleron on January 29, 2014, 12:36:46 AM I guess the question is, why are you trying to build it? Does the py run by itself or does it have exception errors?
freeze or py2exe takes lots of custom tweaking of files, especially if it was written using libraries that use other binaries like OpenSSL. |