Forums

Permission denied while trying to run a process.

Hi, I am trying to run 2 python processes along with each other under one python file. flask_api.py, aiogram_bot.py which I want to run under app.py:

import multiprocessing
import subprocess
PYTHON_PATH="/home/Shaxius/mysite/"
api_process = multiprocessing.Process(
    target=subprocess.run,
    kwargs={
        'args': f'{PYTHON_PATH} flask_api.py',
        'shell': True
    })
bot_process = multiprocessing.Process(
    target=subprocess.run,
    kwargs={
        'args': f'{PYTHON_PATH} aiogram_bot.py',
        'shell': True
    })  
if __name__ == '__main__':
    api_process.start()
    bot_process.start()

When I run app.py it gives me error:

/bin/sh: 1: /home/Shaxius/mysite/: Permission denied

Tried this and it didn't help.

chmod +x /path/to/your.file

With the code that you have above, you're trying to run a file called "/home/Shaxius/mysite/", passing in the parameter "flask_api.py" in one case and "aiogram_bot.py" in the other. Because "/home/Shaxius/mysite/" is a directory, not a command, it's failing.

I would expect your variable "PYTHON_PATH" to point to a Python interpreter like "/usr/local/bin/python3.10" rather than a directory.

Thank you, yes that solved the problem. I misunderstood the PYTHON_PATH meaning.

Glad that worked!