PyInstaller stops working when I import something from PySide - python

When I build a simple hello world application with PyInstaller, it works as expected. But as soon as I import something from PySide it stops working. Here is the main.py:
from PySide.QtGui import QApplication
print "Hello World"
The build process goes smoothly, but the resulting binary doesn't work:
(pyside) C:\Test\pyinstaller>main\dist\main\main.exe
Traceback (most recent call last):
File "<string>", line 5, in <module>
File "C:\Test\pyinstaller\PyInstaller\loader\iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Test\pyinstaller\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide", lin
e 55, in <module>
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide", lin
e 11, in _setupQtDirectories
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide._util
s", line 87, in get_pyside_dir
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide._util
s", line 83, in _get_win32_case_sensitive_name
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide._util
s", line 58, in _get_win32_short_name
WindowsError: [Error 123] The filename, directory name, or volume label syntax i
s incorrect.
Notice that this happens even though I'm just importing a PySide module, not actually using it. What should I do?
I am using PyInstaller 2.0 to package an app with PySide 1.2 on 64-bit windows 7. My Python installation is 32-bit:
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
>pip freeze
pyside==1.2.0
pywin32==218
And here is the build message:
(pyside) C:\Test\pyinstaller>python pyinstaller.py ..\main.py
90 INFO: wrote C:\Test\pyinstaller\main\main.spec
113 INFO: Testing for ability to set icons, version resources...
162 INFO: ... resource update available
204 INFO: UPX is available.
1237 INFO: checking Analysis
1237 INFO: building Analysis because out00-Analysis.toc non existent
1238 INFO: running Analysis out00-Analysis.toc
1240 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
1313 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21
022.8_none ...
1314 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc
8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest
1316 INFO: Searching for file msvcr90.dll
1317 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll
1317 INFO: Searching for file msvcp90.dll
1319 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll
1319 INFO: Searching for file msvcm90.dll
1319 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll
1447 INFO: Analyzing C:\Test\pyinstaller\support\_pyi_bootstrap.py
2601 INFO: Analyzing C:\Test\pyinstaller\PyInstaller\loader\archive.py
2687 INFO: Analyzing C:\Test\pyinstaller\PyInstaller\loader\carchive.py
2776 INFO: Analyzing C:\Test\pyinstaller\PyInstaller\loader\iu.py
2800 INFO: Analyzing ..\main.py
2893 INFO: Hidden import 'encodings' has been found otherwise
2894 INFO: Looking for run-time hooks
2895 INFO: Analyzing rthook C:\Test\pyinstaller\support/rthooks/pyi_rth_encoding
s.py
7438 INFO: Warnings written to C:\Test\pyinstaller\main\build\pyi.win32\main\war
nmain.txt
7444 INFO: checking PYZ
7445 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
7445 INFO: building PYZ out00-PYZ.toc
8059 INFO: checking PKG
8060 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
8061 INFO: building PKG out00-PKG.pkg
8072 INFO: checking EXE
8073 INFO: rebuilding out00-EXE.toc because main.exe missing
8073 INFO: building EXE from out00-EXE.toc
8075 INFO: Appending archive to EXE C:\Test\pyinstaller\main\build\pyi.win32\mai
n\main.exe
8151 INFO: checking COLLECT
8151 INFO: building COLLECT out00-COLLECT.toc
EDIT: This happens even if I call from PySide import QtGui as it suggests in this answer.

Encountering same question, solved by using PyInstaller 1.5.

Related

Pyinstaller issue in packaging exe program on win10

Currently i meet issue while packaging exe through pyinstaller .
I create a virtual environmental under pycharm , and my programe is very simple
a = input("please input a :")
b = input("please input b: ")
c = print(a+b)
the code stored in test.py . and then I type pyinstaller -F test.py on pycharm consle , it shows as below . as you seen , many libs not found , and packaing failed .
(venv) C:\cheng\Project\STC_Tool\venv>pyinstaller -v
3.6
(venv) C:\cheng\Project\STC_Tool\venv>pyinstaller -F test.py
67 INFO: PyInstaller: 3.6
67 INFO: Python: 3.7.8
70 INFO: Platform: Windows-10-10.0.18362-SP0
72 INFO: wrote C:\cheng\Project\STC_Tool\venv\test.spec
73 INFO: UPX is not available.
74 INFO: Extending PYTHONPATH with paths
['C:\\cheng\\Project\\STC_Tool\\venv', 'C:\\cheng\\Project\\STC_Tool\\venv']
75 INFO: checking Analysis
77 INFO: Building because C:\cheng\Project\STC_Tool\venv\test.py changed
78 INFO: Initializing module dependency graph...
80 INFO: Caching module graph hooks...
83 INFO: Analyzing base_library.zip ...
2178 INFO: Processing pre-find module path hook distutils
2191 INFO: distutils: retargeting to non-venv dir 'C:\\cheng\\Software\\Python\\lib'
3247 INFO: Caching module dependency graph...
3348 INFO: running Analysis Analysis-00.toc
3351 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\cheng\project\stc_tool\venv\scripts\python.exe
3365 WARNING: lib not found: VERSION.dll dependency of c:\cheng\project\stc_tool\venv\scripts\python.exe
3371 INFO: Analyzing C:\cheng\Project\STC_Tool\venv\test.py
3373 INFO: Processing module hooks...
3374 INFO: Loading module hook "hook-distutils.py"...
3375 INFO: Loading module hook "hook-encodings.py"...
3656 INFO: Loading module hook "hook-pydoc.py"...
3657 INFO: Loading module hook "hook-sysconfig.py"...
3659 INFO: Loading module hook "hook-xml.py"...
3910 INFO: Looking for ctypes DLLs
3915 INFO: Analyzing run-time hooks ...
3917 INFO: Looking for dynamic libraries
3937 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\select.pyd
3947 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\select.pyd
3966 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_socket.pyd
3974 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_socket.pyd
3978 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_lzma.pyd
3994 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_lzma.pyd
4001 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_bz2.pyd
4027 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_bz2.pyd
4052 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_hashlib.pyd
4062 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_hashlib.pyd
4071 WARNING: lib not found: libcrypto-1_1.dll dependency of C:\cheng\Software\Python\DLLs\_hashlib.pyd
4079 WARNING: lib not found: libssl-1_1.dll dependency of C:\cheng\Software\Python\DLLs\_ssl.pyd
4095 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_ssl.pyd
4097 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_ssl.pyd
4106 WARNING: lib not found: libcrypto-1_1.dll dependency of C:\cheng\Software\Python\DLLs\_ssl.pyd
4128 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\unicodedata.pyd
4141 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\unicodedata.pyd
4161 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\pyexpat.pyd
4171 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\pyexpat.pyd
4174 INFO: Looking for eggs
4174 INFO: Python library not in binary dependencies. Doing additional searching...
4180 INFO: Using Python library
4180 INFO: Found binding redirects:
[]
4194 INFO: Warnings written to C:\cheng\Project\STC_Tool\venv\build\test\warn-test.txt
4252 INFO: Graph cross-reference written to C:\cheng\Project\STC_Tool\venv\build\test\xref-test.html
4261 INFO: checking PYZ
4268 INFO: Building because toc changed
4270 INFO: Building PYZ (ZlibArchive) C:\cheng\Project\STC_Tool\venv\build\test\PYZ-00.pyz
4875 INFO: Building PYZ (ZlibArchive) C:\cheng\Project\STC_Tool\venv\build\test\PYZ-00.pyz completed successfully.
4890 INFO: checking PKG
4891 INFO: Building because toc changed
4893 INFO: Building PKG (CArchive) PKG-00.pkg
Traceback (most recent call last):
File "C:\cheng\Software\Python\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\cheng\Software\Python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\cheng\Project\STC_Tool\venv\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
exec(code, spec_namespace)
File "C:\cheng\Project\STC_Tool\venv\test.spec", line 33, in <module>
console=True )
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\api.py", line 436, in __init__
upx_exclude=self.upx_exclude
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\api.py", line 199, in __init__
self.__postinit__()
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\api.py", line 262, in assemble
dist_nm=inm)
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\utils.py", line 220, in checkCache
digest = cacheDigest(fnm, redirects)
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\utils.py", line 365, in cacheDigest
with open(fnm, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: ''
if I remobve -F option and type pyinstaller test.py directly , the packaing would be successfully
(venv) C:\cheng\Project\STC_Tool\venv>pyinstaller test.py
65 INFO: PyInstaller: 3.6
65 INFO: Python: 3.7.8
66 INFO: Platform: Windows-10-10.0.18362-SP0
68 INFO: wrote C:\cheng\Project\STC_Tool\venv\test.spec
70 INFO: UPX is not available.
70 INFO: Extending PYTHONPATH with paths
['C:\\cheng\\Project\\STC_Tool\\venv', 'C:\\cheng\\Project\\STC_Tool\\venv']
70 INFO: checking Analysis
75 INFO: checking PYZ
98 INFO: checking PKG
98 INFO: Building because toc changed
99 INFO: Building PKG (CArchive) PKG-00.pkg
125 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
128 INFO: Bootloader c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
129 INFO: checking EXE
131 INFO: Building because toc changed
132 INFO: Building EXE from EXE-00.toc
134 INFO: Appending archive to EXE C:\cheng\Project\STC_Tool\venv\build\test\test.exe
137 INFO: Building EXE from EXE-00.toc completed successfully.
142 INFO: checking COLLECT
WARNING: The output directory "C:\cheng\Project\STC_Tool\venv\dist\test" and ALL ITS CONTENTS will be REMOVED! Continue? (y/N)y
On your own risk, you can use the option `--noconfirm` to get rid of this question.
2769 INFO: Removing dir C:\cheng\Project\STC_Tool\venv\dist\test
2780 INFO: Building COLLECT COLLECT-00.toc
2830 INFO: Building COLLECT COLLECT-00.toc completed successfully.
but the test.exe flashed and closed after I click , I using screen recording tool capture the flash error
, it shows Error loading Python DLL 'c:\cheng\Project\STC_Tool\venv\dist\test'
the python installed on win10 is python3.7 , and I am using win10 64 bit operating system.
could you please give me some suggestiones .
after unistall pyinstaller and then reinstall pyinstaller again , issue solved.
please considered to update system variable as well.

Error while creating .exe using Pyinstaller

I created simple HelloWorld program and tried to create .exe using PyInstaller
.exe is created but doesnot run.
Errors while Compiling
PS E:\Pot> pyinstaller it.py
62 INFO: PyInstaller: 3.6
62 INFO: Python: 3.8.3
62 INFO: Platform: Windows-10-10.0.18362-SP0
62 INFO: wrote E:\Pot\it.spec
62 INFO: UPX is not available.
62 INFO: Extending PYTHONPATH with paths
['E:\\Pot', 'E:\\Pot']
62 INFO: checking Analysis
62 INFO: Building Analysis because Analysis-00.toc is non existent
62 INFO: Initializing module dependency graph...
62 INFO: Caching module graph hooks...
78 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
File "<string>", line 41, in <module>
File "<string>", line 13, in walk_packages
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\pkgutil.py", line 130, in iter_modules
for name, ispkg in iter_importer_modules(i, prefix):
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\pkgutil.py", line 149, in _iter_file_finder_modules
import inspect
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\inspect.py", line 40, in <module>
import linecache
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\linecache.py", line 11, in <module>
import tokenize
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\tokenize.py", line 32, in <module>
import re
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\re.py", line 145, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Traceback (most recent call last):
File "<string>", line 41, in <module>
File "<string>", line 13, in walk_packages
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\pkgutil.py", line 130, in iter_modules
for name, ispkg in iter_importer_modules(i, prefix):
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\pkgutil.py", line 149, in _iter_file_finder_modules
import inspect
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\inspect.py", line 40, in <module>
import linecache
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\linecache.py", line 11, in <module>
import tokenize
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\tokenize.py", line 32, in <module>
import re
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\re.py", line 145, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
2514 INFO: Processing pre-find module path hook distutils
2514 INFO: distutils: retargeting to non-venv dir 'c:\\users\\paritosh malik\\appdata\\local\\programs\\python\\python38\\lib'
3952 INFO: Caching module dependency graph...
4014 INFO: running Analysis Analysis-00.toc
4014 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\paritosh malik\appdata\local\programs\python\python38\python.exe
4280 INFO: Analyzing E:\Pot\it.py
4280 INFO: Processing module hooks...
4280 INFO: Loading module hook "hook-distutils.py"...
4295 INFO: Loading module hook "hook-encodings.py"...
Traceback (most recent call last):
File "<string>", line 41, in <module>
File "<string>", line 13, in walk_packages
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\pkgutil.py", line 130, in iter_modules
for name, ispkg in iter_importer_modules(i, prefix):
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\pkgutil.py", line 149, in _iter_file_finder_modules
import inspect
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\inspect.py", line 40, in <module>
import linecache
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\linecache.py", line 11, in <module>
import tokenize
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\tokenize.py", line 32, in <module>
import re
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\re.py", line 145, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
4389 INFO: Loading module hook "hook-lib2to3.py"...
4389 INFO: Loading module hook "hook-pydoc.py"...
4389 INFO: Loading module hook "hook-sysconfig.py"...
4389 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
4389 INFO: Loading module hook "hook-xml.py"...
4436 INFO: Loading module hook "hook-_tkinter.py"...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\tkinter\__init__.py", line 39, in <module>
import re
File "c:\users\paritosh malik\appdata\local\programs\python\python38\lib\re.py", line 145, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
4592 ERROR: Tcl/Tk improperly installed on this system.
4608 INFO: Looking for ctypes DLLs
4655 INFO: Analyzing run-time hooks ...
4655 INFO: Including run-time hook 'pyi_rth__tkinter.py'
4655 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
4670 INFO: Looking for dynamic libraries
4717 WARNING: lib not found: pywintypes38.dll dependency of c:\users\paritosh malik\appdata\local\programs\python\python38\lib\site-packages\win32\win32evtlog.pyd
4733 WARNING: lib not found: pywintypes38.dll dependency of c:\users\paritosh malik\appdata\local\programs\python\python38\lib\site-packages\win32\win32api.pyd
4889 INFO: Looking for eggs
4889 INFO: Using Python library c:\users\paritosh malik\appdata\local\programs\python\python38\python38.dll
4889 INFO: Found binding redirects:
[]
4889 INFO: Warnings written to E:\Pot\build\it\warn-it.txt
4936 INFO: Graph cross-reference written to E:\Pot\build\it\xref-it.html
4951 INFO: checking PYZ
4951 INFO: Building PYZ because PYZ-00.toc is non existent
4951 INFO: Building PYZ (ZlibArchive) E:\Pot\build\it\PYZ-00.pyz
5529 INFO: Building PYZ (ZlibArchive) E:\Pot\build\it\PYZ-00.pyz completed successfully.
5545 INFO: checking PKG
5545 INFO: Building PKG because PKG-00.toc is non existent
5545 INFO: Building PKG (CArchive) PKG-00.pkg
5561 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
5561 INFO: Bootloader c:\users\paritosh malik\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
5561 INFO: checking EXE
5561 INFO: Building EXE because EXE-00.toc is non existent
5561 INFO: Building EXE from EXE-00.toc
5576 INFO: Appending archive to EXE E:\Pot\build\it\it.exe
5576 INFO: Building EXE from EXE-00.toc completed successfully.
5576 INFO: checking COLLECT
5576 INFO: Building COLLECT because COLLECT-00.toc is non existent
5592 INFO: Building COLLECT COLLECT-00.toc
5811 INFO: Building COLLECT COLLECT-00.toc completed successfully.
Error while running the .exe
PS E:\Pot> dist\it\it
Python path configuration:
PYTHONHOME = 'E:\Pot\dist\it'
PYTHONPATH = (not set)
program name = 'E:\Pot\dist\it\it.exe'
isolated = 0
environment = 0
user site = 0
import site = 0
sys._base_executable = 'E:\\Pot\\dist\\it\\it.exe'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.executable = 'E:\\Pot\\dist\\it\\it.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'E:\\Pot\\dist\\it\\base_library.zip',
'E:\\Pot\\dist\\it',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
LookupError: unknown encoding: utf-8
Current thread 0x000046f8 (most recent call first):
<no Python frame>
PS E:\Pot>
I tried adding "utf_8.pyc" into encodings folder in base_library.zip but then it shows some other error init_sys_streams
So I think error is in lack of files in base_library.zip
Please Help..
Please Help..
Please Help..
Please Help..
Pyinstaller doesn't support Python 3.8 yet, see this open feature request: https://github.com/pyinstaller/pyinstaller/issues/4311
Try using Python 3.7 instead.

PyInstaller is not creating an .exe file

I'm trying to create an executable file using PyInstaller with my script. For reference, I am using Windows 10 with Python 3.8.0 and PyInstaller version 3.5.
My script is called hello_world.py and it is saved in it's own folder.
print("Hello World!")
In command prompt, I navigate to the folder that hello_world.py is in and run:
pyinstaller hello_world.py
And this is the output:
46 INFO: PyInstaller: 3.5
46 INFO: Python: 3.8.0
46 INFO: Platform: Windows-10-10.0.17763-SP0
62 INFO: wrote F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.spec
78 INFO: UPX is not available.
78 INFO: Extending PYTHONPATH with paths
['F:\\Python\\Python Scripts\\Pyinstaller\\Py installer test',
'F:\\Python\\Python Scripts\\Pyinstaller\\Py installer test']
78 INFO: checking Analysis
78 INFO: Building Analysis because Analysis-00.toc is non existent
78 INFO: Initializing module dependency graph...
93 INFO: Initializing module graph hooks...
93 INFO: Analyzing base_library.zip ...
3592 INFO: running Analysis Analysis-00.toc
3592 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\l&a\appdata\local\programs\python\python38\python.exe
4014 INFO: Caching module hooks...
4014 INFO: Analyzing F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.py
4045 INFO: Loading module hooks...
4045 INFO: Loading module hook "hook-encodings.py"...
4202 INFO: Loading module hook "hook-pydoc.py"...
4202 INFO: Loading module hook "hook-xml.py"...
4405 INFO: Looking for ctypes DLLs
4420 INFO: Analyzing run-time hooks ...
4420 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
4420 INFO: Looking for dynamic libraries
5592 INFO: Looking for eggs
5592 INFO: Using Python library c:\users\l&a\appdata\local\programs\python\python38\python38.dll
5592 INFO: Found binding redirects:
[]
5592 INFO: Warnings written to F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\warn-hello_world.txt
5670 INFO: Graph cross-reference written to F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\xref-hello_world.html
5686 INFO: checking PYZ
5686 INFO: Building PYZ because PYZ-00.toc is non existent
5686 INFO: Building PYZ (ZlibArchive) F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\PYZ-00.pyz
Traceback (most recent call last):
File "c:\users\l&a\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\l&a\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\L&A\AppData\Local\Programs\Python\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.spec", line 18, in <module>
pyz = PYZ(a.pure, a.zipped_data,
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 98, in __init__
self.__postinit__()
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble
self.code_dict = {
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 129, in <dictcomp>
key: strip_paths_in_code(code)
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 652, in strip_paths_in_code
consts = tuple(
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 653, in <genexpr>
strip_paths_in_code(const_co, new_filename)
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 660, in strip_paths_in_code
return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
This creates folders called 'dist' and 'build' and a file called 'hello_world.spec' but the 'dist' folder is empty. What is going wrong?
I search for
TypeError: an integer is required (got type bytes)
Did you read this?
I had this issue in the past, can you please perform the follwing:
open Anaconda prompt or any other IDE per example spyder or Atom terminal, command line as admin and Navigate to the folder where the .py located and run the command as bellow:
In my example the file I want to compile it is getwindowsversion.py
this is will create just standalone .exe can be used,
pyinstaller --onefile getwindowsversion.py
if you want to create regular build,
pyinstaller getwindowsversion.py

How to use pyinstaller with pipenv / pyenv

I am trying to ship an executable from my python script which lives inside a virtual environment using pipenv which again relies on pyenv for python versioning. For that, I want to us pyinstaller.
What I did:
pipenv install pyinstaller
pyinstaller --onefile my_script.py
Output:
40 INFO: PyInstaller: 3.5
40 INFO: Python: 3.6.9
41 INFO: Platform: Linux-4.15.0-65-generic-x86_64-with-debian-stretch-sid
42 INFO: wrote /home/matthaeus/cybathlon/planvec/qt_video_gui_example.spec
44 INFO: UPX is not available.
45 INFO: Extending PYTHONPATH with paths
['/home/matthaeus/cybathlon/planvec', '/home/matthaeus/cybathlon/planvec']
45 INFO: checking Analysis
45 INFO: Building Analysis because Analysis-00.toc is non existent
45 INFO: Initializing module dependency graph...
46 INFO: Initializing module graph hooks...
47 INFO: Analyzing base_library.zip ...
2786 INFO: running Analysis Analysis-00.toc
2801 INFO: Caching module hooks...
2805 INFO: Analyzing /home/matthaeus/cybathlon/planvec/qt_video_gui_example.py
3284 INFO: Processing pre-find module path hook distutils
3285 INFO: distutils: retargeting to non-venv dir '/home/matthaeus/.pyenv/versions/3.6.9/lib/python3.6/distutils/__init__.py'
3972 INFO: Processing pre-safe import module hook setuptools.extern.six.moves
4336 INFO: Processing pre-find module path hook site
4337 INFO: site: retargeting to fake-dir '/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/fake-modules'
6327 INFO: Loading module hooks...
6328 INFO: Loading module hook "hook-numpy.core.py"...
6458 INFO: Loading module hook "hook-sysconfig.py"...
6464 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
6534 INFO: Loading module hook "hook-scipy.py"...
6535 INFO: Loading module hook "hook-PyQt5.py"...
6549 WARNING: Hidden import "sip" not found!
6549 INFO: Loading module hook "hook-pkg_resources.py"...
6788 INFO: Processing pre-safe import module hook win32com
7015 INFO: Loading module hook "hook-numpy.py"...
7015 INFO: Loading module hook "hook-cv2.py"...
7016 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
7048 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
7096 INFO: Loading module hook "hook-pydoc.py"...
7097 INFO: Loading module hook "hook-xml.py"...
7150 INFO: Loading module hook "hook-encodings.py"...
7203 INFO: Loading module hook "hook-setuptools.py"...
7423 WARNING: Hidden import "distutils.command.build_ext" not found!
7680 INFO: Looking for ctypes DLLs
7762 INFO: Analyzing run-time hooks ...
7769 INFO: Including run-time hook 'pyi_rth_pyqt5.py'
7770 INFO: Including run-time hook 'pyi_rth_pkgres.py'
7771 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
7785 INFO: Looking for dynamic libraries
9784 INFO: Looking for eggs
9784 INFO: Python library not in binary dependencies. Doing additional searching...
Traceback (most recent call last):
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 791, in build
exec(code, spec_namespace)
File "/home/matthaeus/cybathlon/planvec/qt_video_gui_example.spec", line 17, in <module>
noarchive=False)
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 243, in __init__
self.__postinit__()
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
self.assemble()
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 575, in assemble
self._check_python_library(self.binaries)
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 681, in _check_python_library
raise IOError(msg)
OSError: Python library not found: libpython3.6mu.so.1.0, libpython3.6m.so, libpython3.6m.so.1.0, libpython3.6.so.1.0
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
I tried the recommended python3-dev and python-dev installations without luck.
Now, I hope someone can enlighten me what is going on here!
Cheers,
Matt
You need to build with CPython shared-library enabled.
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.9
eval "$(pyenv init -)"
Reference: https://github.com/pyenv/pyenv/wiki

pyInstaller executable missing module "_struct" on Ubuntu 12.04 Precise

I would like to package my python project into a UNIX executable. For this I've tried py2exe, cxfreeze and pyInstaller, but nothing worked. Hopefully you can help me with pyinstaller. So here it goes:
I've downloaded the zipfile of pyinstaller-2.0 from http://www.pyinstaller.org/ and unzipped it.
In the folder, I run python pyinstaller.py ../helloworld.py (output listed at the end).
Then I try to execute the file: ./helloworld/dist/helloworld/helloworld
which gives me the output:
mod is NULL - structTraceback (most recent call last):
File "/usr/lib/python2.7/struct.py", line 1, in <module>
from _struct import *
ImportError: No module named _struct
mod is NULL - archiveTraceback (most recent call last):
File "/home/jelle/Downloads/pyinstaller-1.5.1/archive.py", line 42, in <module>
import struct
ImportError: No module named struct
Traceback (most recent call last):
File "<string>", line 25, in <module>
ImportError: No module named archive
I'm using Ubuntu 12.04 with Python 2.7.3. My PYTHONPATH include /usr/lib/python2.7. It looks as if the problem is a missing module _struct, but I have no idea where to find it. I've tried pyinstaller 1.5.1 and the development version, neither work here.
Please help!
The output of python pyinstaller.py ../helloworld.py:
7 INFO: wrote /home/jelle/Downloads/pyinstaller-2.0/helloworld/helloworld.spec
27 INFO: UPX is not available.
583 INFO: checking Analysis
583 INFO: building Analysis because out00-Analysis.toc non existent
583 INFO: running Analysis out00-Analysis.toc
702 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/support/_pyi_bootstrap.py
1570 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/archive.py
1637 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/carchive.py
1701 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/iu.py
1720 INFO: Analyzing ../helloworld.py
1721 INFO: Hidden import 'encodings' has been found otherwise
1721 INFO: Looking for run-time hooks
1721 INFO: Analyzing rthook /home/jelle/Downloads/pyinstaller-2.0/support/rthooks/pyi_rth_encodings.py
2197 INFO: Looking for Python library libpython2.7.so
objdump: section '.dynamic' mentioned in a -j option, but not found in any input file
2308 INFO: Warnings written to /home/jelle/Downloads/pyinstaller-2.0/helloworld/build/pyi.linux2/helloworld/warnhelloworld.txt
2311 INFO: checking PYZ
2311 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
2312 INFO: building PYZ out00-PYZ.toc
2706 INFO: checking PKG
2706 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
2706 INFO: building PKG out00-PKG.pkg
2711 INFO: checking EXE
2712 INFO: rebuilding out00-EXE.toc because helloworld missing
2712 INFO: building EXE from out00-EXE.toc
2772 INFO: Appending archive to EXE /home/jelle/Downloads/pyinstaller-2.0/helloworld/build/pyi.linux2/helloworld/helloworld
2773 INFO: checking COLLECT
2773 INFO: building COLLECT out00-COLLECT.toc
BTW: my helloworld.py simply contains the statement print "hello world". I tried putting #!/usr/bin/python2.7 at the top.
Check the value of the system variable LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
It might point to the wrong python library libpython2.7.so.
In my case, I could fix this by resetting it:
export LD_LIBRARY_PATH=

Categories