import gradio as gr import fns import subprocess subprocess.run(["playwright", "install", "chromium"], check=True) def install_playwright_dependencies(): """ python -m playwright install-deps 명령을 subprocess로 실행 """ try: # 권한 문제가 없다면: subprocess.run(["python", "-m", "playwright", "install-deps"], check=True) # 만약 관리자 권한이 꼭 필요하다면 (Docker나 권한 없는 환경이 아니라면): # subprocess.run(["sudo", "python", "-m", "playwright", "install-deps"], check=True) print("Playwright system dependencies installed successfully.") except subprocess.CalledProcessError as e: print("Failed to install Playwright dependencies.") print("Return code:", e.returncode) print("Command output:", e.output) except FileNotFoundError: print("Python 혹은 playwright를 찾지 못했습니다. pip로 playwright를 설치했는지 확인하세요.") except Exception as e: print("예상치 못한 오류가 발생했습니다:", e) install_playwright_dependencies() with gr.Blocks() as demo: generate = gr.Button() tb = gr.Textbox() generate.click(fn=fns.main, outputs=tb) demo.launch()