I hope this post is rightly placed here…
I have starfted with fastai and executed the following command in the python shell:
from fastai.vision import * from fastai.callbacks.one_cycle import * path = untar_data(URLs.MNIST_SAMPLE) data = ImageDataBunch.from_folder(path) model = simple_cnn((3,16,16,2)) learn = Learner(data, model) learn.metrics=[accuracy] learn.fit(1)
It works fine in the python shell, but when I copy it into a file test.py and call python I get an error when learn.fit(1) starts.
File “C:\Program Files\Python37\lib\multiprocessing\spawn.py”, line 136, in _check_not_importing_main is not going to be frozen to produce an executable.’’’) RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your child processes and you have forgotten to use the proper idiom in the main module: if __name__ == '__main__': freeze_support() ... The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable.
I do not understand why I can run code interactively but not as a python file