diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index 545d0217581a4f8fb082af038d1f41da0743a66e..d615cdab21e1138e78ab1c968027e890a527dd5c 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -2674,12 +2674,12 @@ class Population: with open(gridcode_filename, "w") as file: file.write(self.code_string) - # perhaps create symlink to latest gridcode: note, we use os.replace() - # in case the symlink already exists + # perhaps create symlink if self.grid_options['symlink latest gridcode']: symlink = os.path.join(self.grid_options['tmp_dir'], 'binary_c_grid-latest') - os.unlink(symlink) + if os.path.exists(symlink): + os.unlink(symlink) try: os.symlink(gridcode_filename,symlink)