I believe your subprocess command needs to be like this:
subprocess.run(['/path/to/arduino-cli.exe', 'compile', '--upload', '/path/to/treadmillEncoder.ino', '-p', 'COM4', '-b', 'teensy:avr:teensy31'])
i.e. you need a list containing the command and each argument separately. At least in the...