*Help please! How am I being dumb! grin!*
This example python script runs python via Popen. It simply tries to print
a random number. But the PYTHONPATH is redefined without the system's
python <lib thus it is unable to find the random module.
Bonus: I assume once I can get past this, then I will not longer need the
-S as the builtin site module will be found.
PROGRAM:
import subprocess
import shlex
def run_cmd(cmd):
cmd=shlex.split(cmd)
try:
output=subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except Exception as exc:
print ">>>", exc.output
else:
print output
def main():
cmd='python -S -c "import sys; print sys.path"'
run_cmd(cmd)
print "\n\n"
cmd='python -S -c "import random; print random.randint(0,10)"'
run_cmd(cmd)
if __name__=="__main__":
main()
SPEC:
# -*- mode: python -*-
a = Analysis(['test.py'],
pathex=['C:\\Users\\???\\Desktop\\testing'],
hiddenimports=[],
hookspath=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', 'test.exe'),
debug=False,
strip=None,
upx=True,
console=True )
EXECUTION:
C:\Users\???\Desktop\testing>dist\test.exe
['', 'C:/Users/???/AppData/Local/Temp/_MEI92722',
'C:/Users/???/Desktop/testing/dist', 'C:\\Windows\\system32\\python27.zip',
'C:/User
s/???/AppData/Local/Temp/_MEI92722/\\DLLs',
'C:/Users/???/AppData/Local/Temp/_MEI92722/\\lib',
'C:/Users/???/AppData/Local/Temp/_ME
I92722/\\lib\\plat-win',
'C:/Users/???/AppData/Local/Temp/_MEI92722/\\lib\\lib-tk', 'C:\\PYTHON27']
>>> Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named random
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pyinstaller/-/06XSucySm1cJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyinstaller?hl=en.