[Fixed] ImportError: cannot import name 'deprecated' from 'typing_extensions' – Python

by
Alexei Petrov
nlp python python-3.x spacy

Quick Fix: To resolve the ImportError, you can install a compatible version of typing_extensions using pip install typing_extensions==4.7.1 --upgrade. Additionally, consider upgrading your Python version to 3.10 or 3.11 for improved compatibility.

The Problem:

I’m trying to download the spaCy language pack, but I’m getting an ImportError: cannot import name ‘deprecated’ from ‘typing_extensions’. I’ve tried updating the typing-extensions package, but that didn’t help. I’m using Python 3.7. What’s the best way to fix this issue?

The Solutions:

Solution 1: Use typing_extensions==4.7.1

The error is caused by a version conflict between the `typing_extensions` package and the version required by the `pydantic` package. To resolve this issue, you should install the `typing_extensions` package with the version 4.7.1, which is compatible with the requirements of the `pydantic` package.

To install the typing_extensions package with the version 4.7.1, you can use the following command:

pip install typing_extensions==4.7.1 --upgrade

Once you have installed the typing_extensions package with the correct version, you should be able to successfully install the spacy language pack using the following command:

python -m spacy download en

Solution 2: Update pandas-profiling

Updating pandas-profiling can resolve the issue. You can update pandas-profiling using the command !pip install -U pandas-profiling in Colab. This command will update pandas-profiling to the latest version, which may include a fix for the ImportError.

Q&A

What typing-extensions version should I use?

Use typing_extensions==4.7.1

How to resolve the error on colab?

Restart session and run !pip install -U pandas-profiling

Video Explanation:

The following video, titled "Related Video", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

This video provides further insights and detailed explanations related to the content discussed in the article.