Spaces:
Runtime error
Runtime error
ClaireOzzz
commited on
Commit
•
ab38123
1
Parent(s):
76b8f3b
checking version before installing
Browse files
app.py
CHANGED
@@ -1,8 +1,32 @@
|
|
1 |
import os
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
|
8 |
import gradio as gr
|
|
|
1 |
import os
|
2 |
+
import pkg_resources
|
3 |
+
|
4 |
+
# Check the installed version of pip
|
5 |
+
pip_version = pkg_resources.get_distribution("pip").version
|
6 |
+
desired_pip_version = "23.3.0"
|
7 |
+
|
8 |
+
if pip_version != desired_pip_version:
|
9 |
+
os.system(f'pip install pip=={desired_pip_version}')
|
10 |
+
|
11 |
+
# Check and install the desired version of "spaces" package
|
12 |
+
try:
|
13 |
+
spaces_version = pkg_resources.get_distribution("spaces").version
|
14 |
+
desired_spaces_version = "0.18.0"
|
15 |
+
|
16 |
+
if spaces_version != desired_spaces_version:
|
17 |
+
os.system(f'pip install spaces=={desired_spaces_version}')
|
18 |
+
except pkg_resources.DistributionNotFound:
|
19 |
+
pass # "spaces" package is not installed
|
20 |
+
|
21 |
+
# Check and install the desired version of "gradio" package
|
22 |
+
try:
|
23 |
+
gradio_version = pkg_resources.get_distribution("gradio").version
|
24 |
+
desired_gradio_version = "4.0.2"
|
25 |
+
|
26 |
+
if gradio_version != desired_gradio_version:
|
27 |
+
os.system(f'pip install gradio=={desired_gradio_version}')
|
28 |
+
except pkg_resources.DistributionNotFound:
|
29 |
+
pass # "gradio" package is not installed
|
30 |
|
31 |
|
32 |
import gradio as gr
|