Spaces:
Runtime error
Runtime error
| import subprocess | |
| def run_command(command): | |
| try: | |
| result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True) | |
| return result.stdout.strip() | |
| except subprocess.CalledProcessError as e: | |
| error_message = e.stderr.decode('utf-8') if hasattr(e.stderr, 'decode') else str(e.stderr) | |
| return f"Error: {error_message.strip()}" | |
| if __name__ == "__main__": | |
| pip_actions = [ | |
| "install --upgrade pip", | |
| "install torch", | |
| "install transformers", | |
| "install flask", | |
| "install tensorflow", | |
| ] | |
| commands = [] | |
| for command in pip_actions: | |
| print(f"Executing pip action: {command}") | |
| result = run_command(f"TMPDIR=/home/container/cache python3 -m pip {command}") # IF IT DOESNT WORK MAKE A CACHE DIR | |
| print(f"Result:\n{result}\n{'='*40}\n") | |
| for command in commands: | |
| print(f"Running command: {command}") | |
| result = run_command(f"{command}") | |
| print(f"Result:\n{result}\n{'='*40}\n") | |