Importing file into main.py. everytime you click "run"

Everytime you import a file into main.py it takes forever, not only that, every time you click “run”. It will load it again. Making it impossible to want to check the code you are writing. For example, say in main.py you write " from data_file import data." It will always import this data EVERYTIME you click run and there’s a whole loading process that can take 10 seconds. is there a way around this?!

Hi @goodvibrations1 , welcome to the forums!
Yes, there is a workaround:

  1. Go to your .replit file (Files sidebar > 3 dots> Show Hidden Files)
  2. Below the entrypoint line, add this line:
disableGuessImports = true
  1. Enter kill 1 in the Shell.

Run your repl. It should work now.
Hope this helps!

3 Likes

Hey @goodvibrations1,

Am I correct in understanding that you have your whole dataset exposed as a Python module, and that importing loads and processes for 10 seconds before showing the result?

If it’s possible to change for library from from data_file import data to load_data("myfile.csv") (csv used here as an example), it would let you swap out your large data file with a smaller one you can use for iteration, swapping to the production data once you’re closer to finishing your script.

If you have any further questions, please feel free to ask!

1 Like

for this (and any other new features) to work, first migrate to Nix modules as I’ve detailed here.

1 Like