import sys import subprocess # Write Python info with open(r"C:\Users\simon\wecom_it_smart_desk\backend\env_info.txt", "w") as f: f.write(f"Python: {sys.version}\n") f.write(f"Executable: {sys.executable}\n") # Try to install packages result = subprocess.run( [sys.executable, "-m", "pip", "install", "pytest", "pytest-asyncio", "aiosqlite", "httpx"], capture_output=True, text=True, timeout=120 ) f.write(f"\nInstall stdout:\n{result.stdout}\n") f.write(f"\nInstall stderr:\n{result.stderr}\n") f.write(f"\nInstall RC: {result.returncode}\n") # Check what's installed result2 = subprocess.run( [sys.executable, "-m", "pip", "list"], capture_output=True, text=True, timeout=30 ) f.write(f"\nInstalled packages:\n{result2.stdout}\n")