forked from marc-shade/Ollama-Workbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_openai.py
More file actions
41 lines (36 loc) · 1.13 KB
/
test_openai.py
File metadata and controls
41 lines (36 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
"""
Test script to verify openai import
"""
import sys
import subprocess
import importlib.util
print("Python version:", sys.version)
print("\n=== Testing openai import ===")
# Try to import openai
try:
import openai
print("✅ Successfully imported openai")
print("openai version:", getattr(openai, "__version__", "unknown"))
print("openai path:", openai.__file__)
except ImportError as e:
print("❌ Failed to import openai:", e)
# Check what's installed with pip
print("\n=== Checking pip installation ===")
try:
result = subprocess.run(
[sys.executable, "-m", "pip", "show", "openai"],
capture_output=True,
text=True,
check=False
)
if result.returncode == 0:
print("✅ openai is installed via pip:")
for line in result.stdout.splitlines():
if line.startswith("Name:") or line.startswith("Version:") or line.startswith("Location:"):
print(" ", line)
else:
print("❌ openai is NOT installed via pip")
except Exception as e:
print("Error checking openai installation:", e)
print("\n=== Test complete ===")