Hi!
Looks like I am going to have to force the addition of all the paths in
sys.path into the spec file then build my EXEs.
Unfortunately, even this sucks as those python paths are specific to the
system we build on, so what if the user has python in c:\program
files\python27 instead of the default c:\python27, or of course any other
path they may want? Uggh.
*Hartmut*: I apologize for giving the idea that python is required for our
app. But, since our app uses Popen to run subcommands, it may be the case
that some customer (and does, which is how we found it!) wants to use
python within our app.
*Steve*: Thanks for the idea! I will ponder that.
-- Quentin
On Friday, November 23, 2012 9:03:45 AM UTC-8, Quentin Crain wrote:
>
>
> *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/-/gBYeoFuKdQAJ.
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.