elisemercury / Duplicate-Image-Finder

difPy - Python package for finding duplicate or similar images within folders
https://difpy.readthedocs.io
MIT License
420 stars 65 forks source link

Will not work in a script. #97

Open hesmith1029 opened 4 weeks ago

hesmith1029 commented 4 weeks ago

If I run difPy examples from a Python Console it works. If I put the same commands into a script (test.py) and issue a run command it fails. I think the useful part of the error message that comes back is. 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.

    To fix this issue, refer to the "Safe importing of main module"
    section in https://docs.python.org/3/library/multiprocessing.html

I am using PyCharm 2024.1.2 (Community Edition), python 3.12 on Windows 10. I have tried putting the freeze_support into difPy in the ifName section of the library with no impact. (It is my understanding that this section only runs if dif.py is called stand alone, and with my script that is not the case, so this solution not working is the expected result)

hesmith1029 commented 3 weeks ago

Found a work around. Please close