Skip to content

Commit 2b57bf8

Browse files
committed
More robust package installation for local OS mode
1 parent d316a99 commit 2b57bf8

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

interpreter/terminal_interface/profiles/defaults/01.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,16 @@ def get_function_info(file_path):
215215
time.sleep(2)
216216
print("Attempting to start OS control anyway...\n\n")
217217

218-
for pip_name in ["pip", "pip3"]:
219-
command = f"{pip_name} install open-interpreter[os]"
218+
for pip_combo in [
219+
["pip", "quotes"],
220+
["pip", "no-quotes"],
221+
["pip3", "quotes"],
222+
["pip", "no-quotes"],
223+
]:
224+
if pip_combo[1] == "quotes":
225+
command = f'{pip_combo[0]} install "open-interpreter[os]"'
226+
else:
227+
command = f"{pip_combo[0]} install open-interpreter[os]"
220228

221229
interpreter.computer.run("shell", command, display=True)
222230

interpreter/terminal_interface/profiles/defaults/local-os.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
import sys
21
import os
32
import platform
43
import subprocess
4+
import sys
55
import time
6+
67
import inquirer
78

89
from interpreter import interpreter
910

1011

1112
def get_ram():
1213
import psutil
13-
total_ram = psutil.virtual_memory().total / (1024 * 1024 * 1024) # Convert bytes to GB
14+
15+
total_ram = psutil.virtual_memory().total / (
16+
1024 * 1024 * 1024
17+
) # Convert bytes to GB
1418
return total_ram
1519

1620

1721
def download_model(models_dir, models, interpreter):
1822
# For some reason, these imports need to be inside the function
1923
import inquirer
20-
import wget
2124
import psutil
25+
import wget
2226

2327
# Get RAM and disk information
2428
global get_ram
@@ -533,8 +537,16 @@ def list_ollama_models():
533537
time.sleep(2)
534538
print("Attempting to start OS control anyway...\n\n")
535539

536-
for pip_name in ["pip", "pip3"]:
537-
command = f"{pip_name} install open-interpreter[os]"
540+
for pip_combo in [
541+
["pip", "quotes"],
542+
["pip", "no-quotes"],
543+
["pip3", "quotes"],
544+
["pip", "no-quotes"],
545+
]:
546+
if pip_combo[1] == "quotes":
547+
command = f'{pip_combo[0]} install "open-interpreter[os]"'
548+
else:
549+
command = f"{pip_combo[0]} install open-interpreter[os]"
538550

539551
interpreter.computer.run("shell", command, display=True)
540552

@@ -582,4 +594,3 @@ def list_ollama_models():
582594
"**Warning:** In this mode, Open Interpreter will not require approval before performing actions. Be ready to close your terminal."
583595
)
584596
print("") # < - Aesthetic choice
585-

interpreter/terminal_interface/profiles/defaults/os.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,16 @@
169169
time.sleep(2)
170170
print("Attempting to start OS control anyway...\n\n")
171171

172-
for pip_name in ["pip", "pip3"]:
173-
command = f"{pip_name} install open-interpreter[os]"
172+
for pip_combo in [
173+
["pip", "quotes"],
174+
["pip", "no-quotes"],
175+
["pip3", "quotes"],
176+
["pip", "no-quotes"],
177+
]:
178+
if pip_combo[1] == "quotes":
179+
command = f'{pip_combo[0]} install "open-interpreter[os]"'
180+
else:
181+
command = f"{pip_combo[0]} install open-interpreter[os]"
174182

175183
interpreter.computer.run("shell", command, display=True)
176184

0 commit comments

Comments
 (0)