• Web3.py version 3.15.0
  • Python: Python 3.5.2
  • OS: linux

I have followed @carver 's answer related to Rinkeby failure with web3.py — Could not format value '0x…' as field 'extraData' related to web3.exceptions.ValidationError: The field extraData is 97 bytes, but should be 32. It is quite likely that you are connected to a POA chain. Refer http://web3py.readthedocs.io/en/stable/middleware.html#geth-style-proof-of-authority for more details.:


from web3 import Web3, IPCProvider
# connect to the default geth --dev IPC location
w3 = Web3(IPCProvider('/home/user/POA/private/geth.ipc'))
from web3.middleware import geth_poa_middleware #<===Error occurs

# inject the poa compatibility middleware to the innermost layer
w3.middleware_stack.inject(geth_poa_middleware, layer=0)

# confirm that the connection succeeded

Error I am having:

Traceback (most recent call last):
  File "coder.py", line 4, in <module>
    from web3.middleware import geth_poa_middleware
ImportError: cannot import name geth_poa_middleware

[Q] How could I fix this error (cannot import name geth_poa_middleware)?

  • 2
    Most likely answer is that you are not using the version of web3.py that you expected. From the same environment as you are running coder.py run a pip install -U web3 to get the latest stable version. – carver Jul 19 '18 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.