Saturday, 13 February 2016

qgis - PyInstaller myscript.py - issues: empty dist folder


This question is subsequent to another question: here. The question was solved but I ran into another issue and tried to ask it there but it is worth being its own question I think.


Python version in OSGeo4W.bat the version number is "Python 2.7.5 (Default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32".


I want to make my python script "a.py" into a .exe for distribution.


The start of a.py looks like this:


import sys
import os
import math
path = os.environ['PATH']
pgdal= 'C:\\Program Files\\QGIS Lyon\\share\\gdal;'

os.environ['GDAL_DATA']='C:\\Program Files\\QGIS Lyon\\share\\gdal\\gdal-data'
os.environ['GDAL_DRIVER_PATH']='C:\\Program Files\\QGIS Lyon\\share\\gdal\\gdalplugins'
os.environ['PROJ_LIB']='C:\\Program Files\\QGIS Lyon\\share\\gdal\\projlib'
os.environ['PATH'] = "%s;%s" % (pgdal, path)
try:
from osgeo import osr
from osgeo import gdal
except ImportError:
import osr
import gdal


I used OSGeo4W.bat to run, which was successful:


pip install pyinstaller

In OsGeo4w.bat shell ran as admin, I ran the following commands (only did this once):


SET "PATH="C:\Program Files\QGIS Lyon\share\gdal";%PATH%"
SET "GDAL_DATA=C:\Program Files\QGIS Lyon\share\gdal\gdal-data"
SET "GDAL_DRIVER_PATH=C:\Program Files\QGIS Lyon\share\gdal\gdalplugins"
SET "PROJ_LIB=C:\Program Files\QGIS Lyon\share\gdal\projlib"


Then in the shell I ran:


cd C:\Python27\PyPack

then to attempt to create my executable:


pyinstaller a.py

The output was an addition of 3 items in C:\Python27\PyPack:


> 1) C:\Python27\PyPack\build\a\a.exe.manifest - (this is the only file)
> 2) C:\Python27\PyPack\dist - (empty)
> 3) C:\Python27\PyPack\a.spec


The output in the shell is:


    c:\Python27\PyPack>pyinstaller a.py 
1344 INFO: PyInstaller: 3.1.1
1344 INFO: Python: 2.7.5
1344 INFO: Platform: Windows-8-6.2.9200
1344 INFO: wrote c:\Python27\PyPack\a.spec
1360 INFO: UPX is not available.
1360 INFO: Extending PYTHONPATH with paths ['c:\\Python27\\PyPack', 'c:\\Python27\\PyPack']
1360 INFO: checking Analysis

1360 INFO: Building Analysis because out00-Analysis.toc is non existent
1360 INFO: Initializing module dependency graph...
1360 INFO: Initializing module graph hooks...
1486 INFO: running Analysis out00-Analysis.toc
1581 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable required by c:\progra~1\qgisly~1\bin\python.exe
2831 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_18f8a87fd1919cd9.manifest
2845 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_3da38fdebd0e6822.manifest
2861 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_acd0e4ffe1daef0a.manifest
2878 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_acd388d7e1d8689f.manifest
2893 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_acd40623e1d81331.manifest

3003 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.9177_none ...
3003 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_08e695a3a83b6ce3.manifest
3003 INFO: Searching for file msvcr90.dll
3003 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_08e695a3a83b6ce3\msvcr90.dll
3003 INFO: Searching for file msvcp90.dll
3003 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_08e695a3a83b6ce3\msvcp90.dll
3018 INFO: Searching for file msvcm90.dll
3018 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_08e695a3a83b6ce3\msvcm90.dll
3111 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_18f8a87fd1919cd9.manifest
3111 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_3da38fdebd0e6822.manifest

3111 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_acd0e4ffe1daef0a.manifest
3111 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_acd388d7e1d8689f.manifest
3128 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_acd40623e1d81331.manifest
3128 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8)

-> (9, 0, 30729, 9177)
4299 INFO: Analyzing c:\Python27\PyPack\a.py
7972 INFO: Processing pre-find module path hook distutils
8347 INFO: Processing pre-safe import module hook _xmlplus
13473 INFO: Processing pre-find module path hook site

13488 INFO: site: retargeting to fake-dir 'C:\\PROGRA~1\\QGISLY~1\\apps\\Python27\\lib\\site-packages\\PyInstaller\\fake-modules'
13565 INFO: Processing pre-safe import module hook win32com
15957 INFO: Looking for import hooks ...
15988 INFO: Processing hook hook-distutils.py
Traceback (most recent call last): File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\runpy.py", line 162, in
_run_module_as_main
"__main__", fname, loader, pkg_name) File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\runpy.py", line 72, in
_run_code
exec code in run_globals File "C:\PROGRA~1\QGISLY~1\apps\Python27\Scripts\pyinstaller.exe\__main__.py", line 9, in
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\__main__.py", line 90, in run

run_build(pyi_config, spec_file, **vars(args))
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\building\build_main.py", line 755, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\building\build_main.py", line 701, in build
exec(text, spec_namespace)
File "", line 16, in
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__
self.__postinit__()

File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\building\datastruct.py", line 183, in __postinit__
self.assemble()
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\building\build_main.py", line 434, in assemble
imphook_object.update_dependencies(self.graph)
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\building\imphook.py", line 309, in update_dependencies
self._process_datas(mod_graph)
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\building\imphook.py", line 285, in _process_datas
self.datas.update(set(format_binaries_and_datas(self._module.datas)))
File "C:\PROGRA~1\QGISLY~1\apps\Python27\lib\site-packages\PyInstaller\building\utils.py", line 426, in format_binaries_and_datas
src_root_path_or_glob)) PyInstaller.compat.FileNotFoundError: Path or glob "C:\PROGRA~1\QGISLY~1\apps\Python27\Include\pyconfig.h" not found or matches no files.


c:\Python27\PyPack>

The file a.spechas the following text:


# -*- mode: python -*-

block_cipher = None


a = Analysis(['a.py'],

pathex=['c:\\Python27\\PyPack'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)

pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='a',
debug=False,
strip=False,
upx=True,
console=True )

coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='a')

Can someone please help me decipher the output so I can get a.py into a .exe?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...