{"id":2358,"library":"web3","title":"web3.py","description":"web3.py is a Python library designed for interacting with the Ethereum blockchain. It enables developers to build decentralized applications (dApps), manage Ethereum accounts, send transactions, interact with smart contracts, and query blockchain data. Currently at version 7.15.0, the library follows Semantic Versioning, with major versions introducing significant breaking changes and frequent minor updates for new features and bug fixes.","status":"active","version":"7.15.0","language":"python","source_language":"en","source_url":"https://github.com/ethereum/web3.py","tags":["ethereum","blockchain","web3","smart-contracts","dapp","web3-py"],"install":[{"cmd":"pip install web3","lang":"bash","label":"Core library"},{"cmd":"pip install \"web3[tester]\"","lang":"bash","label":"With EthereumTesterProvider"}],"dependencies":[{"reason":"Required for the EthereumTesterProvider, useful for local testing without a live node.","package":"eth-tester","optional":true}],"imports":[{"symbol":"Web3","correct":"from web3 import Web3"},{"symbol":"AsyncWeb3","correct":"from web3 import AsyncWeb3"},{"symbol":"HTTPProvider","correct":"from web3 import HTTPProvider"},{"symbol":"IPCProvider","correct":"from web3 import IPCProvider"},{"note":"WebsocketProviderV2 was renamed to WebSocketProvider in v7. The old WebsocketProvider (v5) was renamed to LegacyWebSocketProvider and deprecated in v7.","wrong":"from web3 import WebsocketProviderV2 (v6)","symbol":"WebSocketProvider","correct":"from web3 import WebSocketProvider"}],"quickstart":{"code":"import os\nfrom web3 import Web3, HTTPProvider\n\n# Replace with your actual RPC URL, e.g., from Infura, Alchemy, or a local node.\n# It's best practice to use environment variables for sensitive info.\nINFURA_URL = os.environ.get('WEB3_PROVIDER_URL', 'http://127.0.0.1:8545')\n\n# Initialize Web3 with an HTTPProvider\ntry:\n    w3 = Web3(HTTPProvider(INFURA_URL))\n    if w3.is_connected():\n        print(f\"Successfully connected to Ethereum node at {INFURA_URL}\")\n        # Get the latest block number\n        latest_block = w3.eth.block_number\n        print(f\"Latest block number: {latest_block}\")\n    else:\n        print(f\"Failed to connect to Ethereum node at {INFURA_URL}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to connect to an Ethereum node using `HTTPProvider` and retrieve the latest block number. For asynchronous operations, use `AsyncWeb3` and an asynchronous provider like `AsyncHTTPProvider` or `WebSocketProvider`."},"warnings":[{"fix":"Ensure all byte-like inputs match the ABI's specified length exactly, or explicitly disable strict bytes checking via `w3.strict_bytes_type_checking = False` if necessary.","message":"Strict bytes checking is enabled by default in v6. This means ABI arguments expecting a specific bytes length (e.g., bytes4) will only accept 0x-prefixed hex strings or bytes types of that exact length. Ambiguous values will be invalidated.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update method and property calls to use `snake_case`. For example, `w3.eth.getBlock('latest')` becomes `w3.eth.get_block('latest')`.","message":"Most API methods and properties were converted from `camelCase` to `snake_case` in v6 to align with Pythonic conventions. Exceptions include contract methods/events (which follow ABI) and JSON-RPC parameters/returns (which follow RPC spec).","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Instantiate `Web3` for synchronous code and `AsyncWeb3` for asynchronous code. Ensure providers are compatible with the chosen `Web3` instance.","message":"In v6, the `Web3` class was split into `Web3` (for synchronous operations) and `AsyncWeb3` (for asynchronous operations). Providers must match the instance type (e.g., `AsyncWeb3` requires `AsyncHTTPProvider` or `WebSocketProvider`).","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Rewrite custom middleware to conform to the new class-based structure, separating request and response processing. Consult the official migration guide for examples.","message":"The middleware model changed to a class-based system in v7, replacing the older functional middleware. Middleware logic is now separated into `request_processor` and `response_processor` functions.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Remove all reliance on the `web3.ethpm` module. If EthPM-like functionality is still needed, explore alternative solutions or re-implement necessary parts.","message":"The `EthPM` module, deprecated in v6 due to lack of use and functionality issues, was completely removed in v7.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Upgrade your Python environment to version 3.8 or later.","message":"Python 3.7 support was dropped in v7. The library now requires Python 3.8 or newer.","severity":"gotcha","affected_versions":">=7.0.0"},{"fix":"Remove any calls to `w3.geth.miner` methods. These functionalities are no longer relevant in modern Ethereum.","message":"The `geth.miner` namespace and its methods were deprecated in v6 and completely removed in v7, reflecting Geth's transition away from mining (Proof-of-Work) to Proof-of-Stake.","severity":"deprecated","affected_versions":">=6.0.0 (deprecated), >=7.0.0 (removed)"}],"env_vars":null,"search_vec":"'7.15.0':38 'account':24 'applic':20 'blockchain':13,33,62 'break':49 'bug':59 'build':18 'chang':50 'contract':30,66 'current':35 'dapp':21,67 'data':34 'decentr':19 'design':7 'develop':16 'enabl':15 'ethereum':12,23,61 'featur':57 'fix':60 'follow':41 'frequent':52 'interact':9,27 'introduc':47 'librari':6,40 'major':45 'manag':22 'minor':53 'new':56 'py':70 'python':5 'queri':32 'semant':42 'send':25 'signific':48 'smart':29,65 'smart-contract':64 'transact':26 'updat':54 'version':37,43,46 'web3':63,69 'web3-py':68 'web3.py':1,2","created_at":"2026-04-09T18:54:35.890453+00:00","updated_at":"2026-04-17T00:31:47.875771+00:00","problems":[{"fix":"pip install web3","cause":"The 'web3' library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'web3'"},{"fix":"Verify the RPC URL, check network connectivity, ensure the Ethereum node is running and accessible, and potentially increase the timeout setting.","cause":"The web3.py library failed to receive a response from the configured Ethereum RPC provider within the timeout period.","error":"web3.exceptions.TimeExhausted: Provider is not responding to ping"},{"fix":"Ensure the address is a valid 42-character hexadecimal string, starts with '0x', and use `Web3.to_checksum_address()` for verification.","cause":"The provided Ethereum address string is not a valid checksummed address, or is otherwise malformed.","error":"web3.exceptions.InvalidAddress: checksum address is invalid"},{"fix":"Review the smart contract's code for the failing transaction, check input parameters, ensure sufficient gas and value are provided, and simulate the transaction for detailed error messages.","cause":"A smart contract transaction or call reverted due to a `require()` or `revert()` statement within the contract's logic, often because of invalid input or unmet conditions.","error":"ValueError: {'code': -32000, 'message': 'execution reverted'}"},{"fix":"Verify the exact spelling and case of the function name against the smart contract's ABI (e.g., `contract.functions.my_function_name()`).","cause":"The specified contract function name does not exist in the contract's ABI, or there is a typo in the function name when trying to call it.","error":"AttributeError: 'ContractFunctions' object has no attribute 'myFunctionName'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"7.16.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://web3py.readthedocs.io","github":"https://github.com/ethereum/web3.py","docs":null,"changelog":null,"pypi":"https://pypi.org/project/web3/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","serialization","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}