Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.10 deprecation warning for distutils [duplicate]

DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.dir_util import copy_tree

Is it something that I should worry about? Which import should I use to replace the from distutils.dir_util import copy_tree line?

like image 384
Chris P Avatar asked Sep 16 '25 17:09

Chris P


1 Answers

Change from:

from distutils.dir_util import copy_tree
copy_tree(loc_source, loc_destination)

To:

import shutil
shutil.copytree(loc_source, loc_destination)

Or, to replace existing files and folders:

import shutil
shutil.copytree(loc_source, loc_destination, dirs_exist_ok=True)

Documentation: https://docs.python.org/3/library/shutil.html#shutil.copytree

like image 66
Kane Avatar answered Sep 19 '25 07:09

Kane