pyinstall打包的时候能指定用powershell运行吗
用pyinstall打包后好像默认都是cmd,我能不能指定运行的控制台环境为powershell? 修改spec文件就行,然后重新对spec打包就好。import os# 配置控制台环境为PowerShell
exe = os.path.join(os.environ['SystemRoot'], 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
a = Analysis(['your_project.py'],
pathex=['path/to/your/project'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=None,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=None)
exe = EXE(pyz,
a.scripts,
a.binaries + [(exe, 'powershell.exe')],
a.zipfiles,
a.datas,
[],
name='your_project_exe',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
upx_include=[],
runtime_tmpdir=None,
console=True )
mainblog 发表于 2023-4-7 08:54
修改spec文件就行,然后重新对spec打包就好。import os
# 配置控制台环境为Powe ...
试了,还是不行呢。你这个[(exe, 'powershell.exe')]写下面打包的时候报错了,说少一个参数,我放到了Analysis参数里面就不报错了,但是运行了一下还是cmd,没有变PS呢 本帖最后由 云烟成雨 于 2023-4-7 09:24 编辑
mainblog 发表于 2023-4-7 08:54
修改spec文件就行,然后重新对spec打包就好。import os
# 配置控制台环境为Powe ...
#我贴一下我的spec,请大佬帮我看看,这样还是cmd,没有变PS:
# 配置控制台环境为PowerShell
import os
exe = os.path.join(os.environ['SystemRoot'], 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
block_cipher = None
a = Analysis(
['test.py'],
pathex=[],
binaries=[(exe, 'powershell.exe')],
datas=[('testConfig.ini', '.')],
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,
[],
exclude_binaries=True,
name='test',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['network.ico'],
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='test',
)
页:
[1]