Importerror: cannot import name ‘get_terminal_size’ from ‘click.termui’

Importerror_ cannot import name 'get_terminal_size' from 'click.termui'

Importerror: cannot import name ‘get_terminal_size’ from ‘click.termui’ error occurs because of the incompatibility of typer module. This Typer module internally invokes the click module. In click 8.1.0 version few of the functionality is deprecated or removed. But we are using the Older version of Typer and the latest version of click we get this error.

Now let’s come to the solution for this error. One way to upgrade the Typer module which will become compatible with the click module. The second approach is to downgrade the Click module to any version lesser than the 8.1.0 version, Again here the incompatibility will go away. Let’s see the command to achieve the same.


importerror: cannot import name ‘get_terminal_size’ from ‘click.termui’ ( Solution ) –

As we have already explained both ways to fix this error.

Approach 1: Upgrading Typer Module –

We can use any python package manager ( Pip, conda , easy_intsall ) to upgrade this Typer Module. But pip is the most popular package manager to install or upgrade. Here is the command for pip package manager to install or upgrade typer module.

pip install typer

The above command will install the latest version for typer. But in case you need release specific version then go for the below one –

pip install typer==0.6.1
importerror cannot import name 'get_terminal_size' from 'click.termui'
importerror cannot import name ‘get_terminal_size’ from ‘click.termui’

Here we can alter the version of Typer with our requirement.

Although the majority will go with pip package manager but incase you want to opt for conda. Here is the command for the same.

conda install -c conda-forge typer

Since once you upgrade this, It will not call get_terminal_size which is the root cause of this error. This is the fix.

Approach 2: Downgrading Click module –

As it is the reverse of the above. Here we will not upgrade the Typer module but we can downgrade the click module. The lower version of the click contains the same function (get_terminal_size ).

Please rectify the error and let us know in case of any concern.

Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Meet Abhishek ( Chief Editor) , a data scientist with major expertise in NLP and Text Analytics. He has worked on various projects involving text data and have been able to achieve great results. He is currently manages, where he and his team share knowledge and help others learn more about data science.
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner