RUN ERROR from Custom (New) File Names

Hi, Replit newbie here :raising_hand_woman:

Using custom file names (to keep track of my course work) and getting a RUN ERROR when running code from custom (new) files. Console returns error that it’s missing file. How do I create new files, then run from that new file? Thanks!

1 Like

Welcome to the community! Please post the link you your Repl for more specific answers.
The easiest solution is to make a file called, then use it. However, you can still have other Py files. I wasn’t sure what all you needed, so I made drop-downs.

To use one Py file's functions from another, simply import it as you would a library.

You can do this in several ways:

  1. from otherPy import main with “otherPy” being the other Py file (notice that we left off the “.py” extension), and “main” being the function we are importing
  2. from otherPy import * this imports all the functions from the other Py file
    In the two methods above, you can use functions by name. However, a third option exists:
  3. import otherPy this imports all the functions from otherPy, but to use them you must use otherPy.main() instead of main() like you would in the first two options
After importing the other Py file, just make a basic menu to run the other Py files.
choice = int(input("Which file?\n(1)\n(2)\n(3)"))
if choice == 1:
  from pictures import main
elif choice == 2:
  from other import main
elif choice == 3:
  from old import main
I might use a clear command if I were you.
# Thanks to @bigminiboss on for this clear command.
# To use, type "clear()"
clear = lambda: print("\033c", end="", flush=True)
1 Like

Click the three dots and click “Show hidden files”. Next go in the .replit file and change the entrypoint to the file you would like to run.