OpenAIのChatGPT API の非公式 Python ラッパー「pyChatGPT」のインストール

スポンサーリンク

OpenAIのChatGPT API の非公式 Python ラッパー「pyChatGPT」のインストールについて解説しています。

「pyChatGPT(https://github.com/terry3041/pyChatGPT)」は、あくまで「非公式(unofficial)」のPython ラッパーとなり、このラッパーを使用する前に、使用するPCでGoogle Chrome、もしくはChromiumを使用していることを確認してください。また、このライブラリを使用するためには、OpenAI アカウントが必要ですので、事前にアカウントを取得してください。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■pyChatGPTをインストールする

pyChatGPTをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install pyChatGPT

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install pyChatGPT

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting pyChatGPT
Downloading pyChatGPT-0.4.3.1-py3-none-any.whl (23 kB)
Collecting markdownify>=0.11.6
Downloading markdownify-0.11.6-py3-none-any.whl (16 kB)
Collecting undetected-chromedriver>=3.2.1
Downloading undetected-chromedriver-3.2.1.tar.gz (60 kB)
---------------------------------------- 60.0/60.0 kB 1.6 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting PyVirtualDisplay>=3.0
Downloading PyVirtualDisplay-3.0-py3-none-any.whl (15 kB)
Requirement already satisfied: six<2,>=1.15 in c:\users\user_\appdata\roaming\python\python38\site-packages (from markdownify>=0.11.6->pyChatGPT) (1.16.0)
Collecting beautifulsoup4<5,>=4.9
Using cached beautifulsoup4-4.11.1-py3-none-any.whl (128 kB)
Collecting selenium>=4.0.0
Downloading selenium-4.7.2-py3-none-any.whl (6.3 MB)
---------------------------------------- 6.3/6.3 MB 2.6 MB/s eta 0:00:00
Requirement already satisfied: requests in c:\users\user_\appdata\roaming\python\python38\site-packages (from undetected-chromedriver>=3.2.1->pyChatGPT) (2.28.1)
Collecting websockets
Downloading websockets-10.4-cp38-cp38-win_amd64.whl (101 kB)
---------------------------------------- 101.4/101.4 kB 5.7 MB/s eta 0:00:00
Collecting soupsieve>1.2
Using cached soupsieve-2.3.2.post1-py3-none-any.whl (37 kB)
Requirement already satisfied: urllib3[socks]~=1.26 in c:\users\user_\appdata\roaming\python\python38\site-packages (from selenium>=4.0.0->undetected-chromedriver>=3.2.1->pyChatGPT) (1.26.13)
Requirement already satisfied: certifi>=2021.10.8 in c:\users\user_\appdata\roaming\python\python38\site-packages (from selenium>=4.0.0->undetected-chromedriver>=3.2.1->pyChatGPT) (2022.12.7)
Collecting trio~=0.17
Downloading trio-0.22.0-py3-none-any.whl (384 kB)
---------------------------------------- 384.9/384.9 kB 6.0 MB/s eta 0:00:00
Collecting trio-websocket~=0.9
Using cached trio_websocket-0.9.2-py3-none-any.whl (16 kB)
Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests->undetected-chromedriver>=3.2.1->pyChatGPT) (3.4)
Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests->undetected-chromedriver>=3.2.1->pyChatGPT) (2.1.1)
Collecting exceptiongroup>=1.0.0rc9
Downloading exceptiongroup-1.1.0-py3-none-any.whl (14 kB)
Collecting sortedcontainers
Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Collecting outcome
Using cached outcome-1.2.0-py2.py3-none-any.whl (9.7 kB)
Collecting async-generator>=1.9
Using cached async_generator-1.10-py3-none-any.whl (18 kB)
Collecting sniffio
Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting cffi>=1.14
Using cached cffi-1.15.1-cp38-cp38-win_amd64.whl (178 kB)
Requirement already satisfied: attrs>=19.2.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from trio~=0.17->selenium>=4.0.0->undetected-chromedriver>=3.2.1->pyChatGPT) (22.2.0)
Collecting wsproto>=0.14
Using cached wsproto-1.2.0-py3-none-any.whl (24 kB)
Collecting PySocks!=1.5.7,<2.0,>=1.5.6
Using cached PySocks-1.7.1-py3-none-any.whl (16 kB)
Collecting pycparser
Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Collecting h11<1,>=0.9.0
Downloading h11-0.14.0-py3-none-any.whl (58 kB)
---------------------------------------- 58.3/58.3 kB 3.2 MB/s eta 0:00:00
Building wheels for collected packages: undetected-chromedriver
Building wheel for undetected-chromedriver (setup.py) ... done
Created wheel for undetected-chromedriver: filename=undetected_chromedriver-3.2.1-py3-none-any.whl size=46456 sha256=aa8954c89d861f05b270b09977c5495f4c24c2c1a9fdebf1548e8aab847cd002
Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\ae\b5cd55fb12d3b8d7e3cd839b2d4bf76c10ffc8920e5a42ada8
Successfully built undetected-chromedriver
Installing collected packages: sortedcontainers, PyVirtualDisplay, websockets, soupsieve, sniffio, PySocks, pycparser, outcome, h11, exceptiongroup, async-generator, wsproto, cffi, beautifulsoup4, trio, markdownify, trio-websocket, selenium, undetected-chromedriver, pyChatGPT
Successfully installed PySocks-1.7.1 PyVirtualDisplay-3.0 async-generator-1.10 beautifulsoup4-4.11.1 cffi-1.15.1 exceptiongroup-1.1.0 h11-0.14.0 markdownify-0.11.6 outcome-1.2.0 pyChatGPT-0.4.3.1 pycparser-2.21 selenium-4.7.2 sniffio-1.3.0 sortedcontainers-2.4.0 soupsieve-2.3.2.post1 trio-0.22.0 trio-websocket-0.9.2 undetected-chromedriver-3.2.1 websockets-10.4 wsproto-1.2.0

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、pyChatGPTが正常にインストールされたことになります。

なお、今回はpyChatGPTのバージョン0.4.3.1をインストールしました。

コメント

タイトルとURLをコピーしました