はじめに
Open Interpreterは、OpenAIのコードインタープリターをローカルで実行するためのオープンソースの実装です。このツールを使用すると、ユーザーは自分のコンピュータで言語モデルを使用してコードを実行できます。具体的には、Python、JavaScript、Shellなどのコードをローカルで実行できます。インターフェースはChatGPTのような形式で、インストール後にターミナルでinterpreterを実行することでアクセスできます。
本記事ではWindows11でOpen InterpreterのLocalモデルを動作させる方法を紹介します。Windows11では正常に動作しないようなので、エラーの解決方法も記述しています。
環境
| ソフトウェア | バージョン |
|---|---|
| Windows11 | 22621.2134 |
| Python3 | 3.11.5 |
| pip | 23.2.1 |
| Open Interpreter | v0.1.0 |
事前準備
Python3のインストール
Open InterpreterはPythonを使用して動かします。必須要件はPython3.10以上です。 既に環境を構築している方はこの手順はスキップしてください。
-
以下のサイトにアクセスし、3.10以上のバージョンの「Download」リンクをクリックしてください。※2023/09/09現在:Python 3.11.5 https://www.python.org/downloads/

-
ページを下にスクロールし、Files項目から自身の環境にあったインストーラをダウンロードしてください。

-
インストーラをダウンロードしたら、起動してください。

-
インストーラが起動したら、「Add python.exe to PATH」にチェックを入れ、「Install Now」をクリックしてください。

-
インストールが完了したら、「Close」でインストーラを終了してください。

Open Interpreterのインストール
-
コマンドプロンプトまたはPoweshellを起動してください。

-
以下のコマンドを実行し、Code Interpreterをインストールしてください。
C:\Users\WDAGUtilityAccount>pip install open-interpreter
Open Interpreterの実行

- 以下のコマンドを実行し、Code Interpreterを起動してください。
C:\Users\WDAGUtilityAccount>interpreter -y
Welcome to Open Interpreter.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
▌ OpenAI API key not found
To use GPT-4 (recommended) please provide an OpenAI API key.
To use Code-Llama (free but less capable) press enter.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
OpenAI API key: ←何も入力せずにEnter
▌ Switching to Code-Llama...
Tip: Run interpreter --local to automatically use Code-Llama.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Open Interpreter will use Code Llama for local execution. Use your arrow keys to set up the model.
[?] Parameter count (smaller is faster, larger is more capable): 7B ←モデルを選択
> 7B
13B
34B
[?] Quality (lower is faster, higher is more capable): Medium | Size: 4.24 GB, RAM usage: 6.74 GB ←モデルのクオリティを選択
Low | Size: 3.01 GB, RAM usage: 5.51 GB
> Medium | Size: 4.24 GB, RAM usage: 6.74 GB
High | Size: 7.16 GB, RAM usage: 9.66 GB
[?] Use GPU? (Large models might crash on GPU, but will run more quickly) (Y/n): Y ←GPUを使用するかを選択
[?] This instance of `Code-Llama` was not found. Would you like to download it? (Y/n): Y ←Code-Llamaをインストールするかを選択(初回のみ)

-
しかし、「[?]
Code-Llamainterface package not found. Installllama-cpp-python? (Y/n): Y」の項目を実行中にエラーが出現します。 -
一度、Ctrl + CでOpen Interpreterを停止してください。
Install llama-cpp-pythonエラーの解決方法
Windows11の場合、「[?] Code-Llama interface package not found. Install llama-cpp-python? (Y/n): Y」の項目を実行中にエラーが出現します。
解決のためには手動でllama-cpp-pythonをインストールする必要があります。
参考issue: https://github.com/KillianLucas/open-interpreter/issues/63
以下にWindows11でllama-cpp-pythonをインストールする手順を記述します。
必要パッケージのインストール
Windows11では、llama-cpp-pythonのインストール時にエラーが出現します。
pip install llama-cpp-python
~~~
--------------------------------
-- Trying 'NMake Makefiles (Visual Studio 15 2017 x64 v141)' generator - failure
--------------------------------------------------------------------------------
********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.
Building windows wheels for Python 3.11 requires Microsoft Visual Studio 2022.
Get it with "Visual Studio 2017":
https://visualstudio.microsoft.com/vs/
Or with "Visual Studio 2019":
https://visualstudio.microsoft.com/vs/
Or with "Visual Studio 2022":
https://visualstudio.microsoft.com/vs/
********************************************************************************
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for llama-cpp-python
Failed to build llama-cpp-python
ERROR: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects

-
以下のリンクをクリックし、ページ下のすべてのダウンロード項目内の「Tools for Visual Studio」を開き、「Build Tools for Visual Studio 2022」の「ダウンロード」をクリックしてください。 https://visualstudio.microsoft.com/ja/downloads/

-
ダウンロードしたインストーラを起動してください。

-
インストーラが、起動したら「続行」をクリックしてください。

-
インストーラ項目を選択する画面が開いたら、「C++ によるデスクトップ開発」をクリックし、右下の「インストール」をクリックしてください。

-
インストールが完了したら、以下の画面のようになります。インストールが完了したらインストーラを閉じてください。

llama-cpp-pythonのインストール
- コマンドプロンプトから以下のコマンドを実行し、「llama-cpp-python」をインストールしてください。「Successfully installed」と表示されれば成功です。
C:\Users\WDAGUtilityAccount>pip install llama-cpp-python

Code Interpreterの再実行
エラーを解決したので、再度実行し動作を確認します。
- 以下のコマンドを実行し、Code Interpreterを起動してください。
C:\Users\WDAGUtilityAccount>interpreter -y
Welcome to Open Interpreter.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
▌ OpenAI API key not found
To use GPT-4 (recommended) please provide an OpenAI API key.
To use Code-Llama (free but less capable) press enter.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
OpenAI API key:
▌ Switching to Code-Llama...
Tip: Run interpreter --local to automatically use Code-Llama.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Open Interpreter will use Code Llama for local execution. Use your arrow keys to set up the model.
[?] Parameter count (smaller is faster, larger is more capable): 7B
> 7B
13B
34B
[?] Quality (lower is faster, higher is more capable): Medium | Size: 4.24 GB, RAM usage: 6.74 GB
Low | Size: 3.01 GB, RAM usage: 5.51 GB
> Medium | Size: 4.24 GB, RAM usage: 6.74 GB
High | Size: 7.16 GB, RAM usage: 9.66 GB
[?] Use GPU? (Large models might crash on GPU, but will run more quickly) (Y/n): Y
▌ Model set to Code-Llama
>

- すると、先ほど出現したエラーが出現せずに正常に起動します。これで通常通り、プロンプトに記述することでOpen Interpreterを使用することができます。

おまけ
デスクトップからOpen Interpreterを起動する方法を記述します。
-
デスクトップを右クリックし、新規作成>ショートカットをクリックしてください。

-
項目の場所に以下のコマンドを入力してください。
cmd.exe /c interpreter -y

-
任意のショートカット名を入力してください。

-
デスクトップから作成したショートカットを起動することで直接Open Interpreterが立ち上がります。

おわりに
今回はWindows11でOpen Interpreterを動作させる方法を紹介しました。 構築がスムーズにいかず、戸惑ったので記事という形で共有させていただきます。
追記
本issueでは「Visual Studio 2022」をインストールすれば解決できるよ。という記述がみられますが、Visual Studioは容量が大きいため普段利用しない人にとっては無駄が多いです。そこで本記事では必要なパッケージのみをインストール方法を紹介しています。