E
E
Ekaterina2021-11-10 22:34:34
Heroku
Ekaterina, 2021-11-10 22:34:34

Why is there a problem with subprocess.Popen('python self1.py')?

I'm making a selfie bot for a discord server. Bottom line: bots enter voice channels.
There are 12 programs, each for one bot. These 12 programs run with one program.
I need to put a program on heroku.
But the problem is that when I run the program from a computer, everything works, but there is a problem with the hosting:

Code:

import subprocess

subprocess.Popen('python self1.py')
subprocess.Popen('python self2.py')
subprocess.Popen('python self3.py')
subprocess.Popen('python self4.py')
subprocess.Popen('python self5.py')
subprocess.Popen('python self6.py')
subprocess.Popen('python self7.py')
subprocess.Popen('python self8.py')
subprocess.Popen('python self9.py')
subprocess.Popen('python self10.py')
subprocess.Popen('python self11.py')
subprocess.Popen('python self12.py')


('python self1.py') and so on, filenames.


Mistake:
self._execute_child(args, executable, preexec_fn, close_fds,
File "/app/.heroku/python/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python self1.py'
Process exited with status 1
State changed from up to crashed
State changed from crashed to starting
Starting process with command `python self.py`
State changed from starting to up
Traceback (most recent call last):
File "/app/self.py", line 3, in <module>
File "/app/.heroku/python/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/app/.heroku/python/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python self1.py'
Process exited with status 1
State changed from up to crashed
State changed from crashed to starting
Starting process with command `python self.py`
State changed from starting to up
Traceback (most recent call last):
File "/app/self.py", line 3, in <module>
subprocess.Popen('python self1.py')
File "/app/.heroku/python/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/app/.heroku/python/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python self1.py'
Process exited with status 1
State changed from up to crashed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alan Gibizov, 2021-11-11
@neredko1703

Haven't tried this heroku of yours, but I suspect he doesn't know where he has python, so he can't find it. You should try to either explicitly set the path to the python executable file, or pre-patch the system path by adding a folder with python there ... perhaps the file itself is called differently there, for example python3 or p3 ... who knows.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question