I having the problem. When I restart the app from source, the restart works fine. But, when I compile it, the restart code doesn't work properly. This error appears. usage: MyApp [-h] [-c CONFIG] [-C CACHE] [-l LOG] [--devices] [--default-config]
MyApp: error: unrecognized arguments: /home/myapp/MyApp
But, I'm not passing any args. How can I fix it?
If I start the app, its starting fine. It's only on restart that there's a problem.
I'm using debian11 and python 3.9.2. And, i'm using pyinstaller 5.7.0.
Here is my restart code.
<code>
class RestartCommand(Command):
@property
def help(self) -> str:
return "Restarts the app"
def __call__(self, arg: str, user: User) -> Optional[str]:
self._bot.close()
try:
if 'frozen' in sys.builtin_module_names:
executable = sys.executable
if sys.platform == "win32":
subprocess.run([executable] + sys.argv[1:])
else:
subprocess.run([executable, "-m", "__main__"] + sys.argv[1:])
else:
args = sys.argv
if sys.platform == "win32":
subprocess.run([sys.executable] + args)
else:
args.insert(0, sys.executable)
os.execv(sys.executable, args)
except Exception as e:
print("Error while restarting: ", e)
</code>