quoc-khanh commited on
Commit
ba964ad
·
verified ·
1 Parent(s): 7071c81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import gradio as gr
3
  import json
4
  from tqdm import tqdm
@@ -107,8 +108,14 @@ with gr.Blocks() as demo:
107
 
108
  if __name__ == "__main__":
109
  os.environ["USER_AGENT"] = "gradio-hf-space"
110
- os.system("playwright install")
111
- # if not os.path.exists('/home/user/.cache/ms-playwright/'):
112
- # print("Installing Playwright...")
113
- # os.system("playwright install --with-deps")
 
 
 
 
 
 
114
  demo.launch()
 
1
  import os
2
+ import subprocess
3
  import gradio as gr
4
  import json
5
  from tqdm import tqdm
 
108
 
109
  if __name__ == "__main__":
110
  os.environ["USER_AGENT"] = "gradio-hf-space"
111
+ # Tell Playwright to install browsers into the local folder (needed in some environments)
112
+ os.environ["PLAYWRIGHT_BROWSERS_PATH"] = "0"
113
+
114
+ # Use subprocess.run to install Chromium with dependencies
115
+ try:
116
+ subprocess.run(["playwright", "install", "chromium", "--with-deps"], check=True)
117
+ print("Playwright Chromium installed successfully.")
118
+ except subprocess.CalledProcessError as e:
119
+ print("Error during Playwright installation:", e)
120
+
121
  demo.launch()