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,
)