Bitcoin Forum
November 05, 2024, 10:14:37 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Python-BitcoinRPC] No module AuthProxy  (Read 3320 times)
Nontenda (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
April 24, 2013, 11:22:00 AM
Last edit: April 24, 2013, 03:46:02 PM by Nontenda
 #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: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
jj30
Member
**
Offline Offline

Activity: 82
Merit: 10


View Profile
January 28, 2014, 04:40:51 AM
 #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=<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!
jj30
Member
**
Offline Offline

Activity: 82
Merit: 10


View Profile
January 29, 2014, 12:29:06 AM
Last edit: January 29, 2014, 12:44:58 AM by jj30
 #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://<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()
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1036



View Profile WWW
January 29, 2014, 12:36:46 AM
 #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.
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!