Author

Topic: ModuleNotFoundError: No module named 'bitcoinrpc.auth' (Read 98 times)

member
Activity: 65
Merit: 24
The bitcoin package can come from python-bitcoinlib, it may be installed on your system environment because the second script works.

The reason why it returns an error is that the listtransactions() method does not exist. You can see any available method at https://github.com/petertodd/python-bitcoinlib/blob/4b8fa0ced0b7b57fe5fe6254956d6db5fa934732/bitcoin/rpc.py#L336.

Ok thanks, that cleared it up, got it working.
legendary
Activity: 1932
Merit: 1273
The bitcoin package can come from python-bitcoinlib, it may be installed on your system environment because the second script works.

The reason why it returns an error is that the listtransactions() method does not exist. You can see any available method at https://github.com/petertodd/python-bitcoinlib/blob/4b8fa0ced0b7b57fe5fe6254956d6db5fa934732/bitcoin/rpc.py#L336.
member
Activity: 65
Merit: 24

Your system environment has a package with the name bitcoin that is not in your virtualenv.

Why do you say that? I ran pip list while within the virtualenv
staff
Activity: 3458
Merit: 6793
Just writing some code
python-bitcoinrpc creates the package bitcoinrpc. In your second script, you are using the package bitcoin which is completely different. Your system environment has a package with the name bitcoin that is not in your virtualenv.
member
Activity: 65
Merit: 24
Do note if you have multiple installations, using the command python/pip or python3/pip3, might execute a different python version.

Within your current Python environment, make sure you have installed the package. Check using "pip list" command or, run a Python shell, then type out "help('modules')", to see if those particular packages exist. If it does not, the PATH variable on your terminal might haven't yet been set up correctly.

As last resort, You should try to install the package using "conda install " way or install the package directly.

When I do pip list (from within the virtualenv) I see:

bitcoin           1.1.42
pip               22.3.1
python-bitcoinrpc 1.0
setuptools        65.6.3
wheel             0.38.4

When I run the script:

Code:
import bitcoin
from bitcoin.rpc import Proxy

# create a connection to the local bitcoin node
conn = Proxy(
    service_url='http://user:pass@localhost:8332/'
)

print("conn is ")
print(conn)

# list the transactions in the wallet
print(conn.listtransactions())

I get the error:

Code:
    from bitcoin.rpc import Proxy
ModuleNotFoundError: No module named 'bitcoin.rpc'

When I deactivate and run again, I get:

Code:
    print(conn.listtransactions())
AttributeError: 'Proxy' object has no attribute 'listtransactions'

Which is a new problem, but does show that for whatever reason, the bitcoin lib cant be used within a virtual env
legendary
Activity: 1932
Merit: 1273
Do note if you have multiple installations, using the command python/pip or python3/pip3, might execute a different python version.

Within your current Python environment, make sure you have installed the package. Check using "pip list" command or, run a Python shell, then type out "help('modules')", to see if those particular packages exist. If it does not, the PATH variable on your terminal might haven't yet been set up correctly.

As last resort, You should try to install the package using "conda install " way or install the package directly.
member
Activity: 65
Merit: 24

I am having so many problems simply trying to connect to a python script connect to a local bitcoin node running regtest. I posted another thread here using a different Python library https://bitcointalksearch.org/topic/--5431250


Im now trying the library python-bitcoinrpc. I run:

   
Code:
pip3 install python-bitcoinrpc

And the script is:

Code:
import bitcoinrpc.auth
from bitcoinrpc.authproxy import AuthServiceProxy

# Connect to the local Bitcoin node
connection = AuthServiceProxy(
    "http://username:password@localhost:8332",
    network='regtest'  # specify the network parameters as 'regtest'
)

# List the transactions in the wallet
print(connection.listtransactions())

I run it with
Code:
python3 scripts.py 

And I get the response:

Code:
    import bitcoinrpc.auth
ModuleNotFoundError: No module named 'bitcoinrpc.auth'

When I do
Code:
which python

I get:

Code:
/Users/me/opt/anaconda3/bin/python

The python version is  3.9.7


I am truly reaching the end of my tether with this. If anyone has any ideas whats going on, or even has a suggestion of better libraries in different languages - I've spent 3 days on various Python libraries and cannot get any of them working, some I cant even seem to import. Im more experienced with Java and Javascript than Python.
Jump to: