title: How to use PyInstaller with distutils
body: <p>Trying to use pyinstaller with a library that uses distutils. Can't figure out how to use the hooks to get it to bring distutils with it.</p>
  
  <p>All I have in the project is main.py and the hook, which I copied from the pyinstaller hooks directory. It says it finds the hook, so I think the problem is not with the hook. I shouldn't even need the hook - main.py contains only <code>import distutils</code> so you'd think it wouldn't be a hidden import.</p>
  
  <p>Here is the output of the pyinstaller command <code>pyinstaller main.py --additional-hooks-dir ${DIR}/pyinstaller_hooks</code></p>
  
  <pre><code>65 INFO: Python: 3.7.3
  66 INFO: Platform: Linux-5.0.0-36-generic-x86_64-with-debian-buster-sid
  67 INFO: wrote /home/z9/repos/test/main.spec
  69 INFO: UPX is not available.
  70 INFO: Extending PYTHONPATH with paths
  ['/home/z9/repos/test', '/home/z9/repos/test']
  70 INFO: checking Analysis
  73 INFO: Building because hookspath changed
  73 INFO: Initializing module dependency graph...
  75 INFO: Initializing module graph hooks...
  77 INFO: Analyzing base_library.zip ...
  4411 INFO: running Analysis Analysis-00.toc
  4434 INFO: Caching module hooks...
  4445 INFO: Analyzing /home/z9/repos/test/main.py
  4449 INFO: Processing pre-find module path hook   distutils
  4450 INFO: distutils: retargeting to non-venv dir '/home/z9/.pyenv/versions/3.7.3/lib/python3.7/distutils/__init__.py'
  4452 INFO: Loading module hooks...
  4453 INFO: Loading module hook "hook-encodings.py"...
  4527 INFO: Loading module hook "hook-xml.py"...
  4841 INFO: Loading module hook "hook-pydoc.py"...
  4862 INFO: Looking for ctypes DLLs
  4862 INFO: Analyzing run-time hooks ...
  4871 INFO: Looking for dynamic libraries
  5529 INFO: Looking for eggs
  5530 INFO: Using Python library /home/z9/.pyenv/versions/3.7.3/lib/libpython3.7m.so.1.0
  5539 INFO: Warnings written to /home/z9/repos/test/build/main/warn-main.txt
  5584 INFO: Graph cross-reference written to /home/z9/repos/test/build/main/xref-main.html
  5596 INFO: checking PYZ
  5598 INFO: Building because toc changed
  5598 INFO: Building PYZ (ZlibArchive) /home/z9/repos/test/build/main/PYZ-00.pyz
  6144 INFO: Building PYZ (ZlibArchive) /home/z9/repos/test/build/main/PYZ-00.pyz completed successfully.
  6150 INFO: checking PKG
  6150 INFO: Building because /home/z9/repos/test/build/main/PYZ-00.pyz changed
  6150 INFO: Building PKG (CArchive) PKG-00.pkg
  6173 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
  6175 INFO: Bootloader /home/z9/.pyenv/versions/3.7.3/envs/zoetic/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-64bit/run
  6175 INFO: checking EXE
  6176 INFO: Rebuilding EXE-00.toc because pkg is more recent
  6176 INFO: Building EXE from EXE-00.toc
  6176 INFO: Appending archive to ELF section in EXE /home/z9/repos/test/build/main/main
  6216 INFO: Building EXE from EXE-00.toc completed successfully.
  6220 INFO: checking COLLECT
  WARNING: The output directory "/home/z9/repos/test/dist/main" and ALL ITS CONTENTS will be REMOVED! Continue? (y/N)y
  13469 INFO: Removing dir /home/z9/repos/test/dist/main
  13484 INFO: Building COLLECT COLLECT-00.toc
  13550 INFO: Building COLLECT COLLECT-00.toc completed successfully.
  </code></pre>
  
  <p>Here is the output of running the resulting program:</p>
  
  <pre><code>  File "main.py", line 1, in &lt;module&gt;
      import distutils
  ModuleNotFoundError: No module named 'distutils'
  [20846] Failed to execute script main
  </code></pre>
  
  <p>Am I missing something really obvious?</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:
  Tried <code>pyinstaller main.py --hidden-import distutils</code>
  now get:</p>
  
  <pre><code>Traceback (most recent call last):
    File "main.py", line 1, in &lt;module&gt;
      import distutils
    File "/home/z9/.pyenv/versions/3.7.3/envs/zoetic/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
      exec(bytecode, module.__dict__)
    File "distutils/__init__.py", line 44, in &lt;module&gt;
  ImportError: cannot import name 'dist' from 'distutils' (/home/z9/repos/test/dist/main/distutils/__init__.pyc)
  [24692] Failed to execute script main
  </code></pre>