分析および操作ツールであるpandasに生成AI機能を追加するPythonライブラリ「pandasai」のインストールについて解説しています。
「pandasai(https://pandas-ai.readthedocs.io/en/latest/,https://github.com/gventuri/pandas-ai)」はデータを効率的に扱うために開発されたpandasモジュールに生成 AI 機能を追加できる。
■Python
今回のPythonのバージョンは、「3.9.9」を使用しています。(Windows11)(pythonランチャーでの確認)
■pandasaiをインストールする
pandasaiをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。
pip install pandasai
起動後、上記のコマンドを入力し、Enterキーを押します。
なお、今回は、pythonランチャーを使用しており、Python Version 3.9.9にインストールを行うために、バージョンの切り替えを行います。
py -3.9 -m pip install pandasai
切り替えるために、上記のコマンドを入力し、Enterキーを押します。
Defaulting to user installation because normal site-packages is not writeable Collecting pandasai Downloading pandasai-0.6.7-py3-none-any.whl (38 kB) Collecting pandas==1.5.3 Downloading pandas-1.5.3-cp39-cp39-win_amd64.whl (10.9 MB) |████████████████████████████████| 10.9 MB 1.7 MB/s Collecting python-dotenv<2.0.0,>=1.0.0 Using cached python_dotenv-1.0.0-py3-none-any.whl (19 kB) Collecting astor<0.9.0,>=0.8.1 Downloading astor-0.8.1-py2.py3-none-any.whl (27 kB) Collecting ipython<9.0.0,>=8.13.1 Downloading ipython-8.14.0-py3-none-any.whl (798 kB) |████████████████████████████████| 798 kB 6.4 MB/s Collecting matplotlib<4.0.0,>=3.7.1 Downloading matplotlib-3.7.2-cp39-cp39-win_amd64.whl (7.5 MB) |████████████████████████████████| 7.5 MB 72 kB/s Collecting openai<0.28.0,>=0.27.5 Downloading openai-0.27.8-py3-none-any.whl (73 kB) |████████████████████████████████| 73 kB 936 kB/s Collecting pytz>=2020.1 Using cached pytz-2023.3-py2.py3-none-any.whl (502 kB) Collecting numpy>=1.20.3 Downloading numpy-1.25.1-cp39-cp39-win_amd64.whl (15.1 MB) |████████████████████████████████| 15.1 MB 60 kB/s Collecting python-dateutil>=2.8.1 Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB) Collecting pickleshare Downloading pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB) Collecting traitlets>=5 Downloading traitlets-5.9.0-py3-none-any.whl (117 kB) |████████████████████████████████| 117 kB 6.4 MB/s Collecting decorator Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB) Collecting stack-data Downloading stack_data-0.6.2-py3-none-any.whl (24 kB) Collecting colorama Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB) Collecting pygments>=2.4.0 Using cached Pygments-2.15.1-py3-none-any.whl (1.1 MB) Collecting typing-extensions Downloading typing_extensions-4.7.1-py3-none-any.whl (33 kB) Collecting prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30 Downloading prompt_toolkit-3.0.39-py3-none-any.whl (385 kB) |████████████████████████████████| 385 kB ... Collecting jedi>=0.16 Downloading jedi-0.18.2-py2.py3-none-any.whl (1.6 MB) |████████████████████████████████| 1.6 MB 3.2 MB/s Collecting matplotlib-inline Downloading matplotlib_inline-0.1.6-py3-none-any.whl (9.4 kB) Collecting backcall Downloading backcall-0.2.0-py2.py3-none-any.whl (11 kB) Collecting parso<0.9.0,>=0.8.0 Downloading parso-0.8.3-py2.py3-none-any.whl (100 kB) |████████████████████████████████| 100 kB 6.4 MB/s Collecting contourpy>=1.0.1 Downloading contourpy-1.1.0-cp39-cp39-win_amd64.whl (429 kB) |████████████████████████████████| 429 kB 6.4 MB/s Collecting packaging>=20.0 Using cached packaging-23.1-py3-none-any.whl (48 kB) Collecting importlib-resources>=3.2.0 Downloading importlib_resources-6.0.0-py3-none-any.whl (31 kB) Collecting pillow>=6.2.0 Downloading Pillow-10.0.0-cp39-cp39-win_amd64.whl (2.5 MB) |████████████████████████████████| 2.5 MB 939 kB/s Collecting cycler>=0.10 Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB) Collecting pyparsing<3.1,>=2.3.1 Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB) Collecting fonttools>=4.22.0 Downloading fonttools-4.40.0-cp39-cp39-win_amd64.whl (2.0 MB) |████████████████████████████████| 2.0 MB 6.4 MB/s Collecting kiwisolver>=1.0.1 Downloading kiwisolver-1.4.4-cp39-cp39-win_amd64.whl (55 kB) |████████████████████████████████| 55 kB 3.8 MB/s Collecting zipp>=3.1.0 Downloading zipp-3.16.0-py3-none-any.whl (6.7 kB) Collecting tqdm Using cached tqdm-4.65.0-py3-none-any.whl (77 kB) Requirement already satisfied: aiohttp in c:\users\user_\appdata\roaming\python\python39\site-packages (from openai<0.28.0,>=0.27.5->pandasai) (3.8.4) Requirement already satisfied: requests>=2.20 in c:\users\user_\appdata\roaming\python\python39\site-packages (from openai<0.28.0,>=0.27.5->pandasai) (2.31.0) Collecting wcwidth Using cached wcwidth-0.2.6-py2.py3-none-any.whl (29 kB) Collecting six>=1.5 Using cached six-1.16.0-py2.py3-none-any.whl (11 kB) Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\user_\appdata\roaming\python\python39\site-packages (from requests>=2.20->openai<0.28.0,>=0.27.5->pandasai) (2.0.3) Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\user_\appdata\roaming\python\python39\site-packages (from requests>=2.20->openai<0.28.0,>=0.27.5->pandasai) (3.1.0) Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python39\site-packages (from requests>=2.20->openai<0.28.0,>=0.27.5->pandasai) (3.4) Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python39\site-packages (from requests>=2.20->openai<0.28.0,>=0.27.5->pandasai) (2023.5.7) Requirement already satisfied: attrs>=17.3.0 in c:\users\user_\appdata\roaming\python\python39\site-packages (from aiohttp->openai<0.28.0,>=0.27.5->pandasai) (23.1.0) Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\user_\appdata\roaming\python\python39\site-packages (from aiohttp->openai<0.28.0,>=0.27.5->pandasai) (6.0.4) Requirement already satisfied: frozenlist>=1.1.1 in c:\users\user_\appdata\roaming\python\python39\site-packages (from aiohttp->openai<0.28.0,>=0.27.5->pandasai) (1.3.3) Requirement already satisfied: aiosignal>=1.1.2 in c:\users\user_\appdata\roaming\python\python39\site-packages (from aiohttp->openai<0.28.0,>=0.27.5->pandasai) (1.3.1) Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\users\user_\appdata\roaming\python\python39\site-packages (from aiohttp->openai<0.28.0,>=0.27.5->pandasai) (4.0.2) Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\user_\appdata\roaming\python\python39\site-packages (from aiohttp->openai<0.28.0,>=0.27.5->pandasai) (1.9.2) Collecting pure-eval Downloading pure_eval-0.2.2-py3-none-any.whl (11 kB) Collecting executing>=1.2.0 Downloading executing-1.2.0-py2.py3-none-any.whl (24 kB) Collecting asttokens>=2.1.0 Downloading asttokens-2.2.1-py2.py3-none-any.whl (26 kB) Installing collected packages: six, zipp, wcwidth, traitlets, pure-eval, parso, numpy, executing, colorama, asttokens, typing-extensions, tqdm, stack-data, pytz, python-dateutil, pyparsing, pygments, prompt-toolkit, pillow, pickleshare, packaging, matplotlib-inline, kiwisolver, jedi, importlib-resources, fonttools, decorator, cycler, contourpy, backcall, python-dotenv, pandas, openai, matplotlib, ipython, astor, pandasai WARNING: The script f2py.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script tqdm.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script pygmentize.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The scripts fonttools.exe, pyftmerge.exe, pyftsubset.exe and ttx.exe are installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script dotenv.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script openai.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The scripts ipython.exe and ipython3.exe are installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script pai.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed astor-0.8.1 asttokens-2.2.1 backcall-0.2.0 colorama-0.4.6 contourpy-1.1.0 cycler-0.11.0 decorator-5.1.1 executing-1.2.0 fonttools-4.40.0 importlib-resources-6.0.0 ipython-8.14.0 jedi-0.18.2 kiwisolver-1.4.4 matplotlib-3.7.2 matplotlib-inline-0.1.6 numpy-1.25.1 openai-0.27.8 packaging-23.1 pandas-1.5.3 pandasai-0.6.7 parso-0.8.3 pickleshare-0.7.5 pillow-10.0.0 prompt-toolkit-3.0.39 pure-eval-0.2.2 pygments-2.15.1 pyparsing-3.0.9 python-dateutil-2.8.2 python-dotenv-1.0.0 pytz-2023.3 six-1.16.0 stack-data-0.6.2 tqdm-4.65.0 traitlets-5.9.0 typing-extensions-4.7.1 wcwidth-0.2.6 zipp-3.16.0 WARNING: You are using pip version 21.2.4; however, version 23.1.2 is available. You should consider upgrading via the 'C:\Program Files\Python39\python.exe -m pip install --upgrade pip' command.
Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、pandasaiが正常にインストールされたことになりますが、「WARNING」と表示されました。「WARNING」はエラーではなく警告で、インストールは行われているので、今回は一旦無視しています。
なお、今回はpandasaiのバージョン0.6.7をインストールしました。
コメント