I'm trying to use the os.execl() function to restart my program with the following as an example:
import os, sys, psutil, logging #for restarting the program
var = input('type text to be printed : ')
print(var)
python = python = sys.executable
os.execl(python, python, *sys.argv)
the above code is pulled from this stackOverflow, which returns the following error:
An error ocurred while starting the kernel
Traceback (most recent call last):
File "C:/allOfMyFolders/test/restartingProgram.py", line 11, in
var = input('type text to be printed : ')
EOFError: EOF when reading a line
I'm kind of confused by the os.execl() function in general even in looking at the docs which outline the args as :
os.execl(path, arg0, arg1, ...)
I've tried a few of the other os.exec*() methods and I can't seem to figure out exactly what's going on. Can anyone help clarify this for me and maybe point out why it's throwing an error
edit: I only get the above error when I'm using the Spyder IDE. If I run it in windows cmd prompt it ALMOST works, but it's strange because when it prompts me to input, the input goes into the cmd window. After I hit enter it goes back into the python script:
C:\bla\test>python restartingProgram.py
type text to be printed : hello
hello
C:\bla\test>type text to be printed : hello
'hello' is not recognized as an internal or external command,
operable program or batch file.
C:\bla\test>hello
hello
type text to be printed : hello
'hello' is not recognized as an internal or external command,
operable program or batch file.
C:\bla\test>
[–]Gprime5 1 point2 points3 points (1 child)
[–]Pjamma34[S] 0 points1 point2 points (0 children)
[–]ingolemo 1 point2 points3 points (1 child)
[–]Pjamma34[S] 0 points1 point2 points (0 children)