Skip to main content

How to connect to the Ethereum network using Python with

Updated on
Dec 11, 2023

2 min read


You can build Ethereum applications in different programming languages. In this article, we will connect to the Ethereum network using Python.


  • Ethereum Node (We will use QuickNode’s free version)
  • Python installed in your system (version >=3.5.3) and Pip3
  • Install (A Python wrapper for Ethereum node APIs)
  • A text editor

Note: We need Python version >=3.5.3 and install using pip3 install web3.

Python and other library versions are the cause of the common installation problems. Therefore, if you face any problem, try setting up a virtual environment and troubleshoot installation.

Connecting to Ethereum Blockchain

A network of Ethereum nodes is called Ethereum blockchain. To interact with Etherum blockchain, these nodes expose APIs which are available using library.

In addition, we will need a running Ethereum node, therefore, we will connect to one using QuickNode’s free plan. Sign up here and create an Ethereum endpoint.

Screenshot of Quicknode Ethereum Endpoint

We will use to get the latest Ethereum block number. For this, we will use the code snippet given below. 

from web3 import Web3, HTTPProvider
print ("Latest Ethereum block number" , w3.eth.blockNumber)

In this snippet, we are importing library and adding our Ethereum node URL and getting the latest Ethereum block number using w3.eth.blockNumber API.

Now, we will save this code snippet in file and then run it using python command. After running this command we will see the latest Ethereum block number as shown below.

That’s it you have connected through the Ethereum network using Python. In addition, you can learn more APIs to build complex applications on Ethereum.

We ❤️ Feedback!

Let us know if you have any feedback or requests for new topics. We'd love to hear from you.

Share this guide