I know repl starts at the base directory and looks for main.py but I have it inside a src folder. Is there a way I can run that when pressing the "run" button?
I have tried bringing the main.py outside the src folder and it works (with a little rewrite of the imports) but I feel like there's a better way to do this.
repl.it, by default, always run /main.ext
(.ext
determined by the programming language) when you press on the run button. If you have the main file in a non-root directory or with a different file name, repl.it supports a configuration file to set a different command for the run button.
If your main.py
file is at src/main.py
, first create a new file with the name .replit
(saved to the root of the repl) then type the following in the file:
language = "python3"
run = "python src/main.py"
This will tell repl.it to run the command python src/main.py
instead of python main.py
(the default) when you press the run button.
If you also need the cwd to change to src/
, you can add it to the .replit
file as well:
language = "python3"
run = "cd src && python main.py"