pyinstaller 打包总是出现 pyads.structs 模块缺失的问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
maybe4399
V2EX    Python

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

  •  1
     
  •   maybe4399 2024-08-13 20:45:29 +08:00 1452 次点击
    这是一个创建于 482 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我用 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\connectsoftware\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)
    应该怎么处理
    第 1 条附言    2024-08-14 19:53:03 +08:00
    我已解决问题,可查看我的 github: https://github.com/maybeMB/ADSconnection
    第 2 条附言    2024-08-14 19:53:08 +08:00
    我已解决问题,可查看我的 github: https://github.com/maybeMB/ADSconnection
    1 条回复    2024-08-14 15:44:05 +08:00
    zfj1441
        1
    zfj1441  
       2024-08-14 15:44:05 +08:00 via iPhone
    给几个处理方向,1 )升级 python3 2 )使用虚拟环境需要什么库再 pip 安装
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     896 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 22ms UTC 21:10 PVG 5:10 LAX 13:10 JFK 16:10
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86