Why I am unable to import trl package in Jupyter?

168 Views Asked by At

I am trying to import SFTTrainer from trl package. I am getting the error message - ImportError: cannot import name 'override' from 'typing_extensions' (D:\...\..\). I am able to do it perfectly well in Google Colab, no issues. Why is this? How can I import on my local PC/ Jupyter?

I installed the trl package and tried importing SFFTrainer using:

!pip install trl
from trl import SFTTrainer

I tried uninstalling and reinstalling typing-extensions, that did not work. I uninstalled trl and tried installing it from Anaconda powershell prompt and I tried a few other installations, updates and uninstallations. I even tried importing trl from github and then load. None of them is working.

How to resolve this?

1

There are 1 best solutions below

0
Daniel Perez Efremova On

Problem

Seems a version incompatibility problem between typing_extensions and other packages.

Solution

I tested it with Python 3.10 and some pinned versions of the following packages, and it should work for you also.

conda create -n my_env python=3.10
conda activate my_env
pip install openai==1.8.0 typing_extensions==0.4.7 trl

Those packages usually cause dependency errors, so this should fix your current problem and future ones.

Extra Ball

There is a similar issue in the openai repository: https://github.com/openai/openai-python/issues/751