I am struggling with deployment because of problems with Python subprocesses I experience on PA but not my local machine.
I'm using flask. To isolate the issue I created a route in app/routes.py
:
def test_subprocess_function():
try:
test_command = "print(2 + 3)"
import subprocess
process = subprocess.Popen(
[sys.executable, '-c', test_command],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
stdout, stderr = process.communicate()
# Check for errors in stderr
if process.returncode != 0:
return f"Subprocess error: {stderr.strip()}"
return f"Subprocess output: {stdout.strip()}"
except Exception as e:
return f"Error: {str(e)}"
The result of navigating to test-subprocess is this error: unable to load configuration from print(2 + 3)
What does this error message mean? From what I understand, I should be able to use subprocesses on PA.