我正在尝试在Windows 7 64位系统上使用distutils.dir_util。从我各种搜索中得到的信息来看,我可能需要单独安装一些distutils包?我确实有基本的distutils包可用,但它似乎被大幅简化和许多组件丢失。尝试研究distutils和windows总是引导我到Python构建脚本以及如何将distutils打包为可重新分发的Python项目或构建EXE文件,而这不是我感兴趣的。我只是无法确定从哪里获取这些代码。
虽然已经过了很长时间,但我想我是通过MSI安装程序安装Python的,不确定是否还有其他常见的方法。这是我的解释器输出:
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
>>> distutils.dir_util
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'dir_util'
好的,看起来可以使用以下代码实现:
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils.core
>>> distutils.dir_util
<module 'distutils.dir_util' from 'C:\apps\Python27\lib\distutils\dir_util.pyc'>
有没有人能解释一下为什么需要这种方法,或者它是如何工作的?