

私はpyautoguiを使って、GUIの自動化プログラムを作成しました。  
`python main.py`をコマンドラインで実行すると作動します。  
プログラムの構成は以下の通りです。

[code]

    zoom_auto_controller_app/main.py
    zoom_auto_controller_app/setup.py
    zoom_auto_controller_app/zoom_controller
    zoom_controller/controller
    zoom_controller/models
    zoom_controller/templates
    zoom_controller/views
    
[/code]

私はこのアプリをcx_Freezeを用いてexe化し、配布しようと考えました。  
cx_Freezeの最初のステップ、`python setup.py build`は成功しました。  
しかし、次のステップ、`python setup.py bdist_msi`でAttributeerrorが出ます。  
そのエラーメッセージは以下の通りです。

[code]

    Traceback (most recent call last):
      File "setup.py", line 77, in <module>
        shortcutDir="ZoomProgramMenu",
      File "C:\Users\kohei\Anaconda3\lib\site-packages\cx_Freeze\dist.py", line 342, in setup
        distutils.core.setup(**attrs)
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
        cmd_obj.run()
      File "C:\Users\kohei\Anaconda3\lib\site-packages\cx_Freeze\windist.py", line 
    390, in run
        install = self.reinitialize_command('install', reinit_subcommands = 1)     
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\__init__.py", line 207, in reinitialize_command
        cmd = _Command.reinitialize_command(self, command, reinit_subcommands)     
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\_distutils\cmd.py", line 306, in reinitialize_command
        reinit_subcommands)
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\_distutils\dist.py", line 939, in reinitialize_command
        command = self.get_command_obj(command_name)
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\_distutils\dist.py", line 859, in get_command_obj
        cmd_obj = self.command_obj[command] = klass(self)
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\__init__.py", line 172, in __init__
        _Command.__init__(self, dist)
      File "C:\Users\kohei\Anaconda3\lib\site-packages\setuptools\_distutils\cmd.py", line 62, in __init__
        self.initialize_options()
      File "C:\Users\kohei\Anaconda3\lib\site-packages\cx_Freeze\dist.py", line 248, in initialize_options
        distutils.command.install.install.initialize_options(self)
    AttributeError: module 'setuptools._distutils.command' has no attribute 'install'
    
[/code]

setup.pyの内容も以下に示します。

[code]

    import os
    import sys
    
    from cx_Freeze import setup, Executable
    
    
    os.environ['TCL_LIBRARY'] = 'C:\\Users\\kohei\\anaconda3\\tcl\\tcl8.6'
    os.environ['TK_LIBRARY'] = 'C:\\Users\\kohei\\anaconda3\\tcl\\tk8.6'
    
    base = None
    if sys.platform == "win32":
        base = "Win32GUI"
    
    packages = [
        "csv",
        "datetime",
        "os",
        "pathlib",
        "pyautogui",
        "string",
        "subprocess",
        "termcolor",
        "time",
        "xlrd",
    ]
    
    excludes = [
        "lxml",
        "matplotlib",
        "numpy",
        "pandas",
        "tkinter",
    ]
    
    includes = [
        'zoom_controller',
        'zoom_controller.models',
        'zoom_controller.controller',
        'zoom_controller.templates',
        'zoom_controller.views',
        ]
    
    build_exe_options = {
        "packages":packages,
        "excludes":excludes,
        "includes":includes,
    }
    
    directory_table = [
    (
        "ProgramMenuFolder",
        "TARGETDIR",
        ".",
    ),
    (
        "ZoomProgramMenu",
        "ProgramMenuFolder",
        "ZoomAutomator",
    ),
                    ]
    
    msi_data = {
        "Directory": directory_table,
    }
    
    setup(
        name = "zoom_auto_controller_app",
        version = "1.1.0",
        description = "Zoom Automator",
        options = {'build_exe': build_exe_options,
                    'bdist_msi': {'data': msi_data}},
        executables = [
            Executable(
                'main.py',
                base=base,
                shortcutName="ZoomAutomator",
                shortcutDir="ZoomProgramMenu",
            )
        ])
    
    
[/code]

なぜエラーが起こるのかわかりません。  
是非解決法を教えていただきたいです。  
いかなるコメントもお待ちしております。

なお、エラーに関わってそうなパッケージのバージョンは以下です。

  * cx_Freeze-6.2
  * setuptools-50.0.0


CC BY-SA 4.0
2020-09-01T14:10:20.657
70056
2021-02-21T07:38:53.980
2021-02-21T07:38:53.980
3060
41730
question
python anaconda setuptools cx-freeze
cx_FreezeでAttributeErrorが出る。：module 'setuptools._distutils.command' has no attribute 'install'