0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Python の OpenAI の api を用いたコードでImportError: cannot import name 'BaseTransport' from 'httpx' というエラーが表示される

Posted at

はじめに

数ヶ月前に書いたPythonのコードを実行した際、

ImportError: cannot import name 'BaseTransport' from 'httpx' (/usr/local/lib/python3.12/site-packages/httpx/__init__.py). Did you mean: 'ASGITransport'?

と表示された。
日本語の記事があまり出て来ず、対処法がすぐに分からなかったため備忘録

原因

OpenAI Python APIライブラリが1.xに移行されたのが原因。 -> 詳細
気付かないうちにライブラリだけアップデートされてしまった状態。

対処法

pip3 install openai==0.28.1

を実行するのが応急処置である。

時間のある時に新しい書き方へ移行して、最新版のライブラリに対応後

pip install openai --upgrade

を実行することで、最新版に更新できる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?