'Auto Py To Exe: Couldn't find pymysql import

Python script (v3.6) runs fine in PyCharm, however when the same is converted via Auto Py To Exe then gives following error in CMD.

Traceback (most recent call last):
  File "export_members.py", line 2, in <module>
ModuleNotFoundError: No module named 'pymysql'
[13936] Failed to execute script export_members

Similar error is given if pyinstaller is used to generate an executable, is there a way i can specify import (pymysql) with either one?

Edit: .spec file

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['export_members.py'],
             pathex=['C:\\Users\\x64\\PycharmProjects\\export_members'],
             binaries=[],
             datas=[],
             hiddenimports=['pymysql'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='export_members',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='export_members')

Trying with following from CMD:

pyinstaller export_members.spec


Solution 1:[1]

Ran following once more, although i had it already installed:

pip install PyMySQL

Generated the executable using Pyinstaller and it worked fine.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ayub