-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_setup.py
More file actions
100 lines (81 loc) · 2.59 KB
/
Copy pathverify_setup.py
File metadata and controls
100 lines (81 loc) · 2.59 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""
验证脚本 - 检查环境和依赖是否正确安装
Windows 兼容版本 (无 emoji)
"""
def check_imports():
"""检查核心库是否可导入"""
print("=" * 60)
print("Checking dependencies...")
print("=" * 60)
checks = [
("openai", "OpenAI API Client"),
("anthropic", "Anthropic API Client"),
("tiktoken", "Token Counter"),
("pydantic", "Data Validation"),
("dotenv", "Environment Variables"),
]
success = []
failed = []
for package, description in checks:
try:
__import__(package)
print(f"[OK] {package:<20} - {description}")
success.append(package)
except ImportError:
print(f"[FAIL] {package:<20} - {description} (not installed)")
failed.append(package)
print("\n" + "=" * 60)
print(f"Result: {len(success)}/{len(checks)} libraries available")
if failed:
print(f"Missing: {', '.join(failed)}")
print("\nInstall command:")
print(f" pip install {' '.join(failed)}")
return False
else:
print("[OK] All core dependencies installed")
return True
def check_env():
"""检查环境变量"""
import os
from pathlib import Path
print("\n" + "=" * 60)
print("Checking environment variables...")
print("=" * 60)
# 尝试加载 .env 文件
env_file = Path(".env")
if env_file.exists():
print("[OK] Found .env file")
try:
from dotenv import load_dotenv
load_dotenv()
except ImportError:
print("[WARN] python-dotenv not installed, cannot load .env")
else:
print("[WARN] .env file not found")
print("Tip: Copy .env.example to .env and fill in your API Key")
# 检查关键环境变量
api_key = os.getenv("OPENAI_API_KEY")
if api_key:
masked_key = api_key[:7] + "..." + api_key[-4:]
print(f"[OK] OPENAI_API_KEY: {masked_key}")
else:
print("[FAIL] OPENAI_API_KEY not set")
return False
return True
def main():
"""主函数"""
print("\n" + "Python Agent Development Environment Check")
# 检查导入
imports_ok = check_imports()
# 检查环境变量(不强制要求)
env_ok = check_env()
print("\n" + "=" * 60)
if imports_ok:
print("[OK] Environment verified! Ready to start.")
if not env_ok:
print("[WARN] API key not configured (optional for testing)")
else:
print("[ERROR] Please install missing dependencies first.")
print("=" * 60)
if __name__ == "__main__":
main()