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 · 93 天前 · 824 次点击
    这是一个创建于 93 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我用 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)
    应该怎么处理
    第 1 条附言  ·  92 天前
    我已解决问题,可查看我的 github: https://github.com/maybeMB/ADSconnection
    第 2 条附言  ·  92 天前
    我已解决问题,可查看我的 github: https://github.com/maybeMB/ADSconnection
    1 条回复    2024-08-14 15:44:05 +08:00
    zfj1441
        1
    zfj1441  
       92 天前 via iPhone
    给几个处理方向,1 )升级 python3 2 )使用虚拟环境需要什么库再 pip 安装
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5681 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 01:38 · PVG 09:38 · LAX 17:38 · JFK 20:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.