How can I fix Openai and googletrans dependency error

181 Views Asked by At

googletrans 4.0.0rc1 requires httpx==0.13.3, but you have httpx 0.26.0 which is incompatible. openai 1.8.0 requires httpx<1,>=0.23.0, but you have httpx 0.13.3 which is incompatible.

I am trying to use both openai and googletrans library in my code but I have this dependency error. How can I fix this.

I try downgrading openai library but the problem is that it doesn't have the function I want in that version. I try upgrading googletrans but it has not been released since 2020.

1

There are 1 best solutions below

1
Bhavitha On
You can fix this dependency error by using virtual environments.

#create a virtual environment for the first application
subprocess.run([sys.executable, "-m","venv","app1_venv"])
subprocess.run(["source","app1_venv/bin/activate"],shell=True)
subprocess.run(["pip","install","googletrans==4.0.0-rc1","httpx==0.13.3"])

#create a virtual environment for the first application
subprocess.run([sys.executable, "-m","venv","app2_venv"])
subprocess.run(["source","app2_venv/bin/activate"],shell=True)
subprocess.run(["pip","install","openai","httpx==0.27.0"])