StoneSeller commited on
Commit
9b05987
·
verified ·
1 Parent(s): 7550275

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -1,27 +1,21 @@
1
  import subprocess
2
  import sys
3
 
4
- # Function to install specific package versions
5
  def install(package):
6
- subprocess.check_call([sys.executable, "-m", "pip", "install", package])
7
 
8
- # Ensure NumPy and pandas versions are compatible
9
  try:
10
  import numpy as np
11
- if not np.__version__.startswith("1.23"):
12
- print(f"Detected incompatible NumPy version {np.__version__}. Downgrading to 1.23.5...")
13
- install("numpy==1.23.5")
14
- except ImportError:
15
- print("NumPy not found. Installing NumPy 1.23.5...")
16
- install("numpy==1.23.5")
17
-
18
- try:
19
  import pandas as pd
20
- if not pd.__version__.startswith("1.5"):
21
- print(f"Detected incompatible pandas version {pd.__version__}. Downgrading to 1.5.3...")
 
22
  install("pandas==1.5.3")
23
  except ImportError:
24
- print("pandas not found. Installing pandas 1.5.3...")
 
25
  install("pandas==1.5.3")
26
 
27
  # Ensure other dependencies are installed
 
1
  import subprocess
2
  import sys
3
 
4
+ # Function to install or reinstall specific packages
5
  def install(package):
6
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "--force-reinstall", package])
7
 
8
+ # Ensure NumPy and pandas are compatible
9
  try:
10
  import numpy as np
 
 
 
 
 
 
 
 
11
  import pandas as pd
12
+ if not (np.__version__.startswith("1.23") and pd.__version__.startswith("1.5")):
13
+ print(f"Detected incompatible versions. Reinstalling NumPy and pandas...")
14
+ install("numpy==1.23.5")
15
  install("pandas==1.5.3")
16
  except ImportError:
17
+ print("NumPy or pandas not found. Installing compatible versions...")
18
+ install("numpy==1.23.5")
19
  install("pandas==1.5.3")
20
 
21
  # Ensure other dependencies are installed