Auto Py To Exe:找不到pymysql导入

时间:2019-10-31 10:54:53

标签: python pyinstaller

Python脚本(v3.6)在PyCharm中运行良好,但是当通过Auto Py To Exe转换该脚本时,会在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

如果使用pyinstaller来生成可执行文件,则会出现类似的错误,是否可以通过任一方法指定import(pymysql)?

编辑:.spec文件

# -*- 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')

尝试使用CMD进行以下操作:

pyinstaller export_members.spec

1 个答案:

答案 0 :(得分:0)

尽管我已经安装了它,但还是再次关注了它:

pip install PyMySQL

使用Pyinstaller生成可执行文件,并且运行良好。