Taorat 2023-12-29 12:27 采纳率: 0%
浏览 5

pyinstaller打包多文件时遇到问题

pyinstaller打包多文件时遇到问题:
cyclegan是自己写的模块,在pycharm的时候可以通过subprocess.Popen来达到运行另一个py文件,但是项目打包exe之后会出现py路径问题
请问各位我应该怎么修改


import cyclegan

def run_script(script_name, args=None):
    def run():
        command = ['python', script_name]
        if args:
            command.extend(args)
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)

        while True:
            output = process.stdout.readline()
            if output == '' and (process.poll() is not None):
                break
            if output:
                if command[1] in [cyclegan.__file__, train.__file__]:
                    update_text_area(output, command[1])
                else:
                    break

    threading.Thread(target=run).start()

spec文件内容如下

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


block_cipher = None


a = Analysis(
    ['gui.py', 'train.py', 'test.py', 'cyclegan.py', 'mydatasets.py', 'utils.py'],
    pathex=[],
    binaries=[],
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    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='gui',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)


  • 写回答

2条回答 默认 最新

  • 虫虫仙人 2023-12-29 12:55
    关注
    
    a = Analysis(
        ['snake.py'],
        pathex=['C:\\Users\xxx\\PycharmProjects\\pythonProject1'],
        binaries=[],
        datas=[('C:\\Users\xxx\\PycharmProjects\\pythonProject1\\猫咪吃东西.wav', '.')],
        hiddenimports=[],
        hookspath=[],
        hooksconfig={},
        runtime_hooks=[],
        excludes=[],
        win_no_prefer_redirects=False,
        win_private_assemblies=False,
        cipher=block_cipher,
        noarchive=False,
    )
    
    评论

报告相同问题?

问题事件

  • 创建了问题 12月29日

悬赏问题

  • ¥66 换电脑后应用程序报错
  • ¥50 array数据同步问题
  • ¥15 pic16F877a单片机的外部触发中断程序仿真失效
  • ¥15 Matlab插值拟合差分微分规划图论
  • ¥15 keil5 target not created
  • ¥15 C/C++数据与算法请教
  • ¥15 怎么找志同道合的伙伴
  • ¥20 如何让程序ab.eXe自已删除干净硬盘里的本文件自己的ab.eXe文件
  • ¥50 爬虫预算充足,跪巨佬
  • ¥15 滑块验证码拖动问题悬赏