I run my Python script with
python3.7 -m opencryptobot.START -lvl 20
opencryptobot is a folder here and START is a module. At some point I'd like to restart the script with this code:
os.execl(sys.executable, sys.executable, *sys.argv)
I use this code because it worked perfectly for my other scripts that I don't execute with the -m argument. So the above code will be executed at some point and then I get this error:
ModuleNotFoundError: No module named 'opencryptobot'
Which sounds correct since opencryptobot is just a folder and not a module. I played around with various versions of os.exec to see if I’m able to restart it but nothing really works.
So my question is, how can I restart my script if I run it the way I do?
This is a minimal version of my folder structure:
.
├── LICENSE
├── Pipfile
├── Pipfile.lock
├── README.md
├── opencryptobot
│ ├── START.py
│ ├── config.py
│ ├── constants.py
│ ├── database.py
│ ├── emoji.py
│ ├── plugin.py
│ ├── plugins
│ │ ├── about.py
│ │ ├── admin.py
│ │ └── alltimehigh.py
│ ├── ratelimit.py
│ ├── telegrambot.py
│ └── utils.py
└── start.sh
I execute START from the root folder.