我想使用copy_tree
函数将一个目录的内容复制到另一个目录中。以下是我的代码:
copy_tree('/opt/Deployment/scripts/image', '/opt/Deployment/dist-packages/job-123')
目录image
中的几个文件被复制到job-123
,但在此之后,我收到此错误:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/rpyc/core/protocol.py", line 305, in _dispatch_request
res = self._HANDLERS[handler](self, *args)
File "/usr/local/lib/python2.7/dist-packages/rpyc/core/protocol.py", line 535, in _handle_call
return self._local_objects[oid](*args, **dict(kwargs))
File "/usr/local/lib/python2.7/dist-packages/rpyc/core/service.py", line 157, in exposed_execute
execute(text, self.exposed_namespace)
File "<string>", line 2, in execute
File "<string>", line 5, in <module>
File "../installModel.py", line 17, in <module>
copy_tree('/opt/Deployment/scripts/image', '/opt/Deployment/dist-packages/job-123')
File "/usr/lib/python2.7/distutils/dir_util.py", line 163, in copy_tree
verbose=verbose, dry_run=dry_run))
File "/usr/lib/python2.7/distutils/dir_util.py", line 167, in copy_tree
dry_run=dry_run)
File "/usr/lib/python2.7/distutils/file_util.py", line 148, in copy_file
_copy_file_contents(src, dst)
File "/usr/lib/python2.7/distutils/file_util.py", line 44, in _copy_file_contents
fdst = open(dst, wb)
IOError: [Errno 2] No such file or directory: /opt/Deployment/dist-packages/job-123/lib/utils.pyc
现在,此文件utils.pyc
位于lib
子目录的源目录中,它应该被复制到目标中的同一子目录中。为什么copy_tree
期望它已存在并抛出错误?