How to check the Polars version in Python

Before working with Polars, we must ensure the correct version of Polars is installed on our system. We can check if the correct Polars version is installed in the following ways:

  • Using the pip3 show command

  • Using the __version__ attribute

Method 1: Using the pip3 show command

Let’s look at how to check the currently installed version of Polars using the pip3 show command.

  • First, install the Polars library using the following command if you haven’t already:
     pip3 install polars
    
  • After installation, get information about the Polars package, including the version using the command:
     pip3 show polars
    

Method 2: Using the __version__ attribute

Let’s look at how to check the currently installed version of Polars using the __version__ attribute.

  • As Polars is already installed, launch a Python environment using the command:
    python3
    
  • Import the Polars library using the command:
    import polars as pl
    
  • To check the currently installed version of Polars, by executing the command:
    print(pl.__version__)
    
  • Exit the Python environment using the command:
    exit()
    

Playground

Run any of the methods listed above in the terminal below to check the installed Polars version.

Note: We’ve already installed Python in the terminal below. Execute the command python3 --version to check the Python version.

Terminal 1
Terminal
Loading...
Copyright ©2024 Educative, Inc. All rights reserved