- Web3.py version: 4.2.1
- Python: 3.5.2
- OS: linux
- geth version:
1.8.0-unstable
- I am running
geth
with--shh
flag and--rpcapi "admin,eth,net,web3,debug,shh"
from web3 import Web3, HTTPProvider
web3 = Web3(HTTPProvider('http://localhost:8545'))
print ("web3 =", web3.version.api) #4.2.1
print(web3.shh) #error occurs
When I try to run following code above, I am having following error:
Traceback (most recent call last):
File "dd.py", line 11, in <module>
print(web3.shh)
AttributeError: 'Web3' object has no attribute 'shh'
[Q] How could I fix this error?
Best Answer
For
web3.py==5.x.x
GethShh
For
web3.py==4.x.x
=> We have to add the following line of code in order to fix the error for the
web3.py
:=> We also have to add the following line for web3.js. Than use
shh
.Please see following solution for
web3.py
:Please see following solution for
web3.js
:Example code: