I have the below ps code to generate an executable using myfile.spec:
python -O -m PyInstaller -v
[System.Environment]::SetEnvironmentVariable('USER', $arr[0])
[System.Environment]::SetEnvironmentVariable('PASSWD', $arr[1])
python -O -m PyInstaller myfile.spec --distpath ../dist --onefile -n myfile
Contents of myfile.spec:
added_files = [
('config.yaml', '.')
]
a = Analysis(['myfile.py'],
pathex=['myfile'],
datas=added_files,
hiddenimports = [
'pandas._libs.tslibs.np_datetime',
],
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='myfile',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )
I did a print(os.environ) in myfile.py and the env vars for USER and PASSWD are not present. What's the best way to set these variables in the environment to be used by the python file?