Author

Topic: [Python-BitcoinRPC] No module AuthProxy (Read 3320 times)

newbie
Activity: 13
Merit: 0
June 23, 2014, 09:03:00 PM
#5
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= -rpcuser= -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!

Could you please tell me if this works for python 3.4 or only for 2.7?
legendary
Activity: 1512
Merit: 1036
January 28, 2014, 07:36:46 PM
#4
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.
member
Activity: 82
Merit: 10
January 28, 2014, 07:29:06 PM
#3
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://:@localhost:8332")
        h.sendfrom('', '', 0.00110000)
        pass

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MainWindow(parent = None,id = -1)
    frame.Show()
    app.MainLoop()
member
Activity: 82
Merit: 10
January 27, 2014, 11:40:51 PM
#2
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= -rpcuser= -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!
newbie
Activity: 19
Merit: 0
April 24, 2013, 06:22:00 AM
#1
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:[email protected]: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
Jump to: