1

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如果用于生成可执行文件,则会给出类似的错误,有没有一种方法可以使用其中任何一个指定导入(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
4

1 回答 1

0

尽管我已经安装了它,但又跑了一次:

pip install PyMySQL

使用 Pyinstaller 生成可执行文件,它工作正常。

于 2019-10-31T14:20:57.377 回答