machinewrapped / gpt-subtrans

Open Source project using LLMs to translate SRT subtitles
Other
311 stars 36 forks source link

module 'openai' has no attribute 'OpenAI' #83

Closed godv23 closed 7 months ago

godv23 commented 7 months ago

Saturday, 22:02:31 - Translating scene number 1 Saturday, 22:02:31 - Failed to translate scene 1 (module 'openai' has no attribute 'OpenAI')... finishing Saturday, 22:02:31 - No subtitles translated

thanks

machinewrapped commented 7 months ago

There was a major change to the OpenAI library, that's the new way to call it. I assume you're installing from source, as I didn't publish a release with the upgrade yet.

You'll need to upgrade the library with pip install --upgrade openai or pip install --upgrade -r requirements.txt.

Make sure the virtual environment is active if there is one (the install script creates one) - if you use the Visual Studio Code terminal it should be activated automatically. Alternatively, delete the envsubtrans folder and run install.bat/install.sh to recreate the virtual environment with the latest libraries :-)

machinewrapped commented 7 months ago

I've added a check that will give a more useful error message if the OpenAI library needs updating.

n-endashi commented 7 months ago

I have installed by dragging and dropping the folder as described: Simply unzip to a folder and run gui-subtrans.exe. I did the pip install --upgrade openai and it seemed to complete just fine but I'm still getting the same error.

PS C:\Users\real name removed\Downloads\gui-subtrans> pip install --upgrade openai Requirement already satisfied: openai in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (1.3.5) Requirement already satisfied: anyio<4,>=3.5.0 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from openai) (3.7.1) Requirement already satisfied: distro<2,>=1.7.0 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from openai) (1.8.0) Requirement already satisfied: httpx<1,>=0.23.0 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from openai) (0.25.2) Requirement already satisfied: pydantic<3,>=1.9.0 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from openai) (2.5.2) Requirement already satisfied: tqdm>4 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from openai) (4.65.0) Requirement already satisfied: typing-extensions<5,>=4.5 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from openai) (4.8.0) Requirement already satisfied: idna>=2.8 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from anyio<4,>=3.5.0->openai) (3.4) Requirement already satisfied: sniffio>=1.1 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from anyio<4,>=3.5.0->openai) (1.3.0) Requirement already satisfied: exceptiongroup in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from anyio<4,>=3.5.0->openai) (1.2.0) Requirement already satisfied: certifi in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from httpx<1,>=0.23.0->openai) (2022.12.7) Requirement already satisfied: httpcore==1. in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from httpx<1,>=0.23.0->openai) (1.0.2) Requirement already satisfied: h11<0.15,>=0.13 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from httpcore==1.->httpx<1,>=0.23.0->openai) (0.14.0) Requirement already satisfied: annotated-types>=0.4.0 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from pydantic<3,>=1.9.0->openai) (0.6.0) Requirement already satisfied: pydantic-core==2.14.5 in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from pydantic<3,>=1.9.0->openai) (2.14.5) Requirement already satisfied: colorama in c:\users\real name removed\appdata\local\programs\python\python39\lib\site-packages (from tqdm>4->openai) (0.4.6)

machinewrapped commented 7 months ago

Hmm, that is interesting - v1.3.5 is the latest OpenAI library, so it must be using a different version at runtime... looks like something is broken in the distribution. I'll have to investigate what happened. I've "unreleased" v0.4.6 - can you try the previous release?

machinewrapped commented 7 months ago

OK, hopefully this is fixed now - can you try v0.4.7? https://github.com/machinewrapped/gpt-subtrans/releases/tag/v0.4.7

I recommend deleting the existing folder or unzipping to a different folder, as PyInstaller has made some big changes to the file & folder structure.

godv23 commented 7 months ago

it worded
thank you ~

n-endashi commented 7 months ago

I am not getting the error any longer either. Thanks for the quick attention!

machinewrapped commented 7 months ago

Great!