pyinstaller 打包总是出现 pyads.structs 模块缺失的问题

102 天前
 maybe4399
我用 2.7.18 版本的 32 位 python 写了一个与 ads 进行通讯的程序,但是在使用 pyinstaller 打包后运行时总是出现:

Traceback (most recent call last):
File "connect.py",line 7,in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py",line 395,in load_module
File "site-packages\pyads\__init__.py",line 8,in <module>
ImportError:No module named structs
[6236]Failed to execute script connect

的问题,下面是我打包使用的 spec 文件:

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

block_cipher = None


a = Analysis(['connect.py'],
pathex=['E:\\code_for_work\\working\\connect_software'],
binaries=[],
datas=[],
hiddenimports=[
'pynput.keyboard._win32',
'pynput.mouse._win32',
'pyads',
'pyads.structs',
'pyads.ads',
'pyads.connection',
'pyads.pyads_ex',
'pyads.constants',
'pyads.symbol',
'pyads.structs',
'six.moves',
'importlib.util'
],
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,
a.binaries,
a.zipfiles,
a.datas,
[],
name='connect',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )

我在 hiddenimports 中放了 pyads.structs ,但没有用
warn 文件:

This file lists modules PyInstaller was not able to find. This does not
necessarily mean this module is required for running you program. Python and
Python 3rd-party packages include a lot of conditional or optional module. For
example the module 'ntpath' only exists on Windows, whereas the module
'posixpath' only exists on Posix systems.

Types if import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported from within a function
* optional: imported within a try-except-statement

IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
yourself tracking down the missing module. Thanks!

missing module named resource - imported by posix (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named posix - imported by os (conditional, optional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named _dummy_threading - imported by dummy_threading (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
runtime module named six.moves - imported by pynput._util (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named pwd - imported by posixpath (delayed, conditional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named os2 - imported by os (conditional, optional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named _emx_link - imported by os (conditional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named ce - imported by os (conditional, optional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named riscos - imported by os (conditional, optional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named riscospath - imported by os (conditional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named riscosenviron - imported by os (conditional, optional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named fcntl - imported by tempfile (optional), subprocess (conditional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named 'org.python' - imported by pickle (optional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named org - imported by copy (optional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named readline - imported by cmd (delayed, conditional, optional), pdb (delayed, optional), E:\code_for_work\working\connect_software\connect.py (top-level)
missing module named 'importlib.util' - imported by six (conditional), E:\code_for_work\working\connect_software\connect.py (top-level)
invalid module named pyads.structs - imported by pyads (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
invalid module named pyads.ads - imported by pyads (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
invalid module named pyads.connection - imported by pyads (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
invalid module named pyads.pyads_ex - imported by pyads (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
invalid module named pyads.constants - imported by pyads (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
invalid module named pyads.symbol - imported by pyads (top-level), E:\code_for_work\working\connect_software\connect.py (top-level)
应该怎么处理
839 次点击
所在节点    Python
1 条回复
zfj1441
101 天前
给几个处理方向,1 )升级 python3 2 )使用虚拟环境需要什么库再 pip 安装

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1064725

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX