-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_environment.py
34 lines (24 loc) · 948 Bytes
/
setup_environment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import subprocess
import sys
import os
import venv
import os
import subprocess
import sys
# Check if Python 3.8.10 or greater is installed
required_version = "3.8.10"
current_version = sys.version.split()[0]
if current_version < required_version:
print(f"Python version {current_version} is not compatible. Installing Python {required_version}...")
subprocess.run(["sudo", "apt-get", "install", f"python{required_version}"])
# Command 1: Switch to root user
subprocess.run(["sudo", "-s"], check=True)
# Command 2: Update the package list
subprocess.run(["apt-get", "update"], check=True)
# Command 3: Install pip
subprocess.run(["apt-get", "install", "python3-pip"], check=True)
# Command 4: Exit from root user shell
subprocess.run(["exit"], check=True)
# Install requirements from requirements.txt
subprocess.run(["pip", "install", "-r", "requirements.txt", "-v"])
print("Virtual environment activated. Installation complete.")