salma-remyx commited on
Commit
04022ce
·
1 Parent(s): fe75f0e

force gradio upgrade

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1,25 +1,24 @@
1
- import os
2
  import subprocess
3
  import sys
 
4
 
5
- # Upgrade Gradio to version 5.5.0
6
  def upgrade_gradio():
7
  subprocess.check_call([sys.executable, "-m", "pip", "install", "gradio==5.5.0"])
8
 
 
9
  try:
10
  import gradio
11
  if gradio.__version__ != "5.5.0":
12
  print(f"Upgrading Gradio from version {gradio.__version__} to 5.5.0...")
13
  upgrade_gradio()
14
- print("Gradio upgraded. Restarting the script...")
15
- # Restart the script after upgrading
16
- os.execv(sys.executable, [sys.executable] + sys.argv)
17
  except ImportError:
18
  print("Gradio not found. Installing Gradio 5.5.0...")
19
  upgrade_gradio()
20
- print("Gradio installed. Restarting the script...")
21
- os.execv(sys.executable, [sys.executable] + sys.argv)
22
-
23
 
24
  import os
25
  import sys
 
 
1
  import subprocess
2
  import sys
3
+ import importlib
4
 
5
+ # Upgrade Gradio to the desired version
6
  def upgrade_gradio():
7
  subprocess.check_call([sys.executable, "-m", "pip", "install", "gradio==5.5.0"])
8
 
9
+ # Attempt to upgrade Gradio before importing it
10
  try:
11
  import gradio
12
  if gradio.__version__ != "5.5.0":
13
  print(f"Upgrading Gradio from version {gradio.__version__} to 5.5.0...")
14
  upgrade_gradio()
15
+ importlib.reload(gradio) # Reload the gradio module to ensure the updated version is used
16
+ print("Gradio upgraded to 5.5.0.")
 
17
  except ImportError:
18
  print("Gradio not found. Installing Gradio 5.5.0...")
19
  upgrade_gradio()
20
+ import gradio # Import Gradio after installation
21
+ print("Gradio installed and imported.")
 
22
 
23
  import os
24
  import sys