Pyinstaller setting icon with one file not working - python

I'm trying to generate a one-file executable with Pyinstaller and it always fails if I try to add an icon, but when I don't ask my computer to add the icon, the app builds successfully. I've tried following the instructions on the following pages:
https://github.com/PySimpleGUI/PySimpleGUI/issues/445
https://shanetully.com/2013/08/cross-platform-deployment-of-python-applications-with-pyinstaller/
Pyinstaller setting icon
but none of them helped me. Based on the page behind the second of those links, I added the following lines (the latter I added since I'm using Windows, but I couldn't understand what if sys.platform == 'win32' else a.binaries, (mentioned at shanetully's website) is supposed to do):
a.datas + [('images/ticon.ico', 'tfolder/images/ticon.ico', 'DATA')]
a.binaries + [('msvcp100.dll', 'C:\\Windows\\System32\\msvcp100.dll', 'BINARY'),
('msvcr100.dll', 'C:\\Windows\\System32\\msvcr100.dll', 'BINARY')]
to the .spec file and copied the icon to tfolder/images.
The error message I got (and have been getting similar or identical messages with previous attempts as well) was the following. (with my computer username replaced with my stackoverflow username:
PS C:\Users\hilssu\Documents\pyinstaller_ij> pyinstaller.exe "C:\Users\hilssu\Documents\pyinstaller_ij\main.spec"
103 INFO: PyInstaller: 3.4
103 INFO: Python: 3.5.6
106 INFO: Platform: Windows-10-10.0.17134-SP0
109 INFO: UPX is not available.
112 INFO: Extending PYTHONPATH with paths
['C:\\Users\\hilssu\\Documents\\pyinstaller_ij',
'C:\\Users\\hilssu\\Documents\\pyinstaller_ij']
114 INFO: checking Analysis
297 INFO: checking PYZ
364 INFO: checking PKG
446 INFO: Building because C:\Users\hilssu\Documents\pyinstaller_ij\build\main\main.exe.manifest changed
446 INFO: Building PKG (CArchive) PKG-00.pkg
156467 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
156523 INFO: Bootloader c:\program files\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
156523 INFO: checking EXE
156525 INFO: Building EXE because EXE-00.toc is non existent
156530 INFO: Building EXE from EXE-00.toc
156537 INFO: SRCPATH [('images\\ticon.ico', None)]
156538 INFO: Updating icons from ['images\\ticon.ico'] to C:\Users\hilssu\AppData\Local\Temp\tmpzh0lbqym
Traceback (most recent call last):
File "c:\program files\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Anaconda3\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 35, in <module>
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\building\api.py", line 433, in __init__
self.__postinit__()
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\building\api.py", line 522, in assemble
icon.CopyIcons(tmpnm, self.icon)
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\utils\win32\icon.py", line 177, in CopyIcons
return CopyIcons_FromIco(dstpath, [srcpath])
File "c:\program files\anaconda3\lib\site-packages\PyInstaller\utils\win32\icon.py", line 137, in CopyIcons_FromIco
win32api.UpdateResource(hdst, RT_GROUP_ICON, i, data)
File "c:\program files\anaconda3\lib\site-packages\win32ctypes\pywin32\win32api.py", line 269, in UpdateResource
handle, type, name, language, lp_data, len(lp_data))
File "c:\program files\anaconda3\lib\site-packages\win32ctypes\core\cffi\_resource.py", line 129, in _UpdateResource
lpData = ffi.from_buffer(cData)
File "c:\program files\anaconda3\lib\site-packages\cffi\api.py", line 340, in from_buffer
return self._backend.from_buffer(self.BCharA, python_buffer)
TypeError: from_buffer() cannot return the address of the raw string within a bytes or unicode object
And yes, I tried googling the last line of the error message on its own, but couldn't find any help that way either.
By the way, this is an app where I actually do want the console to appear when running it.

EDIT: I had to reset the entire computer and this time installed Python as is and did not use Anaconda like I had previously used. This time Pyinstaller worked fine.
ORIGINAL ANSWER (unedited):
I couldn't get Pyinstaller to work, but there is a workaround. You can compile the program first without the icon (pyinstaller.exe --onefile main.py) on the command line and then use a program called Resource Hacker (http://www.angusj.com/resourcehacker/) to change the icon afterwards.
After changing the icon using Resource Hacker, you may need to move the executable to another place for the icon to appear in the file manager. I moved the executable to my SD card and then the icon appeared, and it appears also when I copy the executable back to my computer's hard drive.

Related

Pyinstaller not building because permission denied to USS.jtx

I am getting the following error when using the pyinstaller (pyinstaller --onefile main.py --name pbot.exe) on windows:
329097 INFO: checking PKG
329097 INFO: Building PKG because PKG-00.toc is non existent
329099 INFO: Building PKG (CArchive) PKG-00.pkg
Cannot find ('nltk_data\AppData\Local\Comms\UnistoreDB\USS.jtx', 'C:\Users\adwaith\AppData\Local\Comms\UnistoreDB\USS.jtx', 1, 'x')
Traceback (most recent call last):
File "c:\users\adwaith\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\adwaith\anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\adwaith\anaconda3\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\adwaith\anaconda3\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:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
exec(code, spec_namespace)
File "C:\Users\adwaith\Documents\pbot_win\pbot.spec", line 20, in <module>
exe = EXE(pyz,
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\building\api.py", line 433, in __init__
self.pkg = PKG(self.toc, cdict=kwargs.get('cdict', None),
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\building\api.py", line 199, in __init__
self.__postinit__()
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\building\api.py", line 283, in assemble
archive = CArchiveWriter(self.name, srctoc + mytoc,
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\archive\writers.py", line 336, in __init__
super(CArchiveWriter, self).__init__(archive_path, logical_toc)
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\archive\writers.py", line 63, in __init__
self._add_from_table_of_contents(logical_toc)
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\archive\writers.py", line 88, in _add_from_table_of_contents
self.add(toc_entry) # The guts of the archive.
File "c:\users\adwaith\anaconda3\lib\site-packages\PyInstaller\archive\writers.py", line 383, in add
fh = open(pathnm, 'rb')
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\adwaith\\AppData\\Local\\Comms\\UnistoreDB\\USS.jtx'
I have checked that the location and the USS.jtx files exist on my machine. Also, I tried searching about USS.jtx file but it keeps showing up in the context of git. I do have a Github desktop, so I thought maybe using pyinstaller from inside the git repo is causing problems. I then copied the entire repo to another location on my computer, but the problem persists.
I'm not normally a Windows guy, but I saw your post on Linkedin about this.
It seems to me that the file exists, but you don't have permission to read it. Have a look at this article and ensure that you have permission to read the file.
A quick and dirty way to check this is to just try opening the file in notepad or whatever the basic text editor is called in Windows.
If notepad gives an error on trying to open the file, then you need to fix the permissions. If notepad can open it without any changes to the permissions, then you have some oddness in how you are running pyinstaller.

Error when running pyinstaller (1920, 'LoadLibraryEx', 'System cannot access the file')

Im trying to compile my python script to an exe so that i can send it to friends that can use with without having to install python, but im running into an issue and cant find a solution.
i found a similar issue at Pyinstaller win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryExW', 'System cannot access the file')
but cant post there except as a answer, i tried to add permissions and unhide the 'WindowsApps' folder but nothing seems to work.
Here is what cmd is giving me when running pyinstaller
and 'Systemet kan inte komma åt filen' is swedish for 'System cannot access the file'
100 INFO: PyInstaller: 3.5
101 INFO: Python: 3.7.4
101 INFO: Platform: Windows-10-10.0.18362-SP0
103 INFO: wrote C:\Users\Jonathan\Pictures\shimbot2\gui.spec
106 INFO: UPX is not available.
109 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Jonathan\\Pictures', 'C:\\Users\\Jonathan\\Pictures\\shimbot2']
110 INFO: checking Analysis
110 INFO: Building Analysis because Analysis-00.toc is non existent
111 INFO: Initializing module dependency graph...
116 INFO: Initializing module graph hooks...
119 INFO: Analyzing base_library.zip ...
4140 INFO: running Analysis Analysis-00.toc
Traceback (most recent call last):
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
yield
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\core\cffi\_dll.py", line 26, in _LoadLibraryEx
function_name='LoadLibraryEx')
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\core\cffi\_util.py", line 81, in __call__
self._raise_error(function_name)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\core\cffi\_util.py", line 92, in _raise_error
raise exception
OSError: [WinError 1920] Systemet kan inte komma åt filen
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Jonathan\Pictures\shimbot2\pyinstaller.exe\__main__.py", line 7, in <module>
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "C:\Users\Jonathan\Pictures\shimbot2\gui.spec", line 17, in <module>
noarchive=False)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
self.__postinit__()
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\build_main.py", line 405, in assemble
redirects=self.binding_redirects)[1:])
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\depend\bindepend.py", line 231, in Dependencies
for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\depend\bindepend.py", line 407, in getAssemblyFiles
for assembly in getAssemblies(pth):
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\depend\bindepend.py", line 358, in getAssemblies
res = GetManifestResources(pth)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1005, in GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\utils\win32\winresource.py", line 168, in GetResources
hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1264.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryEx', 'Systemet kan inte komma åt filen')
We don't support the Windows store version of python due to the fact that PyInstaller can't access the DLLs required to build you application. Please use a virtual environment of some kind or install python from https://python.org
I had the same issue with this, apparently it's something to do with shared file systems.
The solution in the post you provided helped me sort the problem, follow this link to guide you to create a virtual environment:
https://www.google.com/amp/s/www.geeksforgeeks.org/python-virtual-environment/amp/
If you have any issues with pyinstaller not being 'recognised as an internal or external command' dont forget to add the virtual environment pyinstaller module to your environmental variables.
I had exactly the same '(1920, 'LoadLibraryEx', 'System cannot access the file')' problem with Pyinstaller and after much thrashing on the problem decided to clean up my Python environment. So I uninstalled Python 3.6 and 3.7 then uninstalled PyCharm and Anaconda.
Then installed Python 3.8 and Pip 3.8 and then Pyinstaller and IT WORKED!!! My hunch is the problem was a conflict between 3.6 and 3.7 but that is just a hunch. I do think PyCharm and Anaconda are great products - - I'm just going to be WAY more careful about my Python environment from here on out.
[BTW Pyinstaller worked flawlessly first time on my Linux development box.]

Pyinstaller not building correctly with PyQt5

I've been trying to build a project using pyinstaller. The project is using PyQt5 and I'm not able to build it correctly. UPX and python are in my PATH. I don't want to mess with any of the package python files so I'm not sure what to do. Here is the cmd output:
C:\Users\John\Desktop\Project_Convar\LarkEnv>pyinstaller -F myProject.py
60 INFO: PyInstaller: 3.5.dev0+cb8d10af6
61 INFO: Python: 3.6.2
62 INFO: Platform: Windows-10-10.0.17134-SP0
64 INFO: wrote C:\Users\John\Desktop\Project_Convar\LarkEnv\myProject.spec
428 INFO: UPX is available.
429 INFO: Extending PYTHONPATH with paths
['C:\\Users\\John\\Desktop\\Project_Convar\\LarkEnv',
'C:\\Users\\John\\Desktop\\Project_Convar\\LarkEnv']
430 INFO: checking Analysis
461 INFO: checking PYZ
478 INFO: checking PKG
479 INFO: Building because toc changed
479 INFO: Building PKG (CArchive) PKG-00.pkg
483 INFO: Executing - upx --lzma -q
...
execute bunch of upx stuff
...
C:\Users\John\AppData\Roaming\pyinstaller\bincache01_py36_64bit\qt5svg.dll
27209 WARNING: One binary added with two internal names.
27209 WARNING: ('libGLESv2.dll',
'C:\\users\\John\\desktop\\project_convar\\larkenv\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
'BINARY')
27211 WARNING: was placed previously at
27211 WARNING: ('PyQt5\\Qt\\bin\\libGLESv2.dll',
'C:\\users\\John\\desktop\\project_convar\\larkenv\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
'BINARY')
C:\Users\John\AppData\Roaming\pyinstaller\bincache01_py36_64bit\qt5qml.dll
Traceback (most recent call last):
File "c:\users\John\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\John\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\John\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\John\appdata\local\programs\python\python36\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\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "C:\Users\John\Desktop\Project_Convar\LarkEnv\myProject.spec", line 32, in <module>
console=True )
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\api.py", line 430, in __init__
strip_binaries=self.strip, upx_binaries=self.upx,
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\api.py", line 196, in __init__
self.__postinit__()
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\api.py", line 281, in assemble
pylib_name=pylib_name)
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\archive\writers.py", line 334, in __init__
super(CArchiveWriter, self).__init__(archive_path, logical_toc)
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\archive\writers.py", line 61, in __init__
self._add_from_table_of_contents(logical_toc)
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\archive\writers.py", line 86, in _add_from_table_of_contents
self.add(toc_entry) # The guts of the archive.
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\archive\writers.py", line 375, in add
code = get_code_object(nm, pathnm)
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\utils.py", line 623, in get_code_object
co = _load_code(modname, filename)
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\utils.py", line 580, in _load_code
loader = importer.find_module(modname)
AttributeError: 'NoneType' object has no attribute 'find_module'
I test and pyinstaller don't have any problem with PyQt5.
use this code in CMD:
pyinstaller --onefile myProject.py

Pyinstaller build process cannot locate pywintypes module

Recently updated my computer to Windows 10 and now pyinstaller is throwing an error. This has been working on my Windows 7 computer for as long as I can remember.
I have tried uninstalling and reinstalling pyinstaller, win32 extentions, and several other things.
Any ideas what could be wrong with my computer settings?
pyinstaller ZENTRAUtility.spec
328 INFO: PyInstaller: 3.3.1
328 INFO: Python: 2.7.14
328 INFO: Platform: Windows-10-10.0.16299
331 INFO: UPX is not available.
332 INFO: Extending PYTHONPATH with paths
['C:\\Users\\mthornbrugh\\PycharmProjects\\ZentraUtility',
'C:\\Users\\mthornbrugh\\PycharmProjects\\ZentraUtility']
332 INFO: checking Analysis
347 INFO: Building because out00-Analysis.toc is bad
348 INFO: Initializing module dependency graph...
351 INFO: Initializing module graph hooks...
430 INFO: running Analysis out00-Analysis.toc
431 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final
executable
required by c:\python27\python.exe
525 INFO: Found
...
...
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "c:\python27\lib\site-packages\PyInstaller\utils\win32\winutils.py",
line 103, in import_pywin32_module
name=module_name, globals={}, locals={}, fromlist=[''])
ImportError: No module named pywintypes
29585 INFO: Loading module hook "hook-setuptools.py"...
29631 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
29634 INFO: Excluding import 'FixTk'
29635 INFO: Excluding import 'Tkinter'
29638 INFO: Loading module hook "hook-encodings.py"...
30174 INFO: Loading module hook "hook-reportlab.pdfbase._fontdata.py"...
30234 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
30236 INFO: Loading module hook "hook-numpy.core.py"...
30318 INFO: Loading module hook "hook-wx.lib.pubsub.py"...
30561 INFO: Loading module hook "hook-win32com.py"...
31109 INFO: Loading module hook "hook-pythoncom.py"...
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "c:\python27\lib\site-packages\PyInstaller\utils\win32\winutils.py",
line 103, in import_pywin32_module
name=module_name, globals={}, locals={}, fromlist=[''])
File "c:\python27\lib\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
ImportError: No module named pywintypes
31572 INFO: Loading module hook "hook-reportlab.lib.utils.py"...
31630 INFO: Looking for ctypes DLLs
31723 INFO: Analyzing run-time hooks ...
31736 INFO: Including run-time hook 'pyi_rth__tkinter.py'
31739 INFO: Including run-time hook 'pyi_rth_pkgres.py'
31742 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
31743 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
31773 INFO: Looking for dynamic libraries
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pyinstaller.exe\__main__.py", line 9, in
<module>
File "c:\python27\lib\site-packages\PyInstaller\__main__.py", line 94, in
run
run_build(pyi_config, spec_file, **vars(args))
File "c:\python27\lib\site-packages\PyInstaller\__main__.py", line 46, in
run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py",
line 791, in main
build(specfile, kw.get('distpath'), kw.get('workpath'),
kw.get('clean_build'))
File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py",
line 737, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py",
line 213, in __init__
self.__postinit__()
File "c:\python27\lib\site-packages\PyInstaller\building\datastruct.py",
line 161, in __postinit__
self.assemble()
File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py",
line 537, in assemble
redirects=self.binding_redirects))
File "c:\python27\lib\site-packages\PyInstaller\depend\bindepend.py", line
222, in Dependencies
for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
File "c:\python27\lib\site-packages\PyInstaller\depend\bindepend.py", line
400, in getAssemblyFiles
for assembly in getAssemblies(pth):
File "c:\python27\lib\site-packages\PyInstaller\depend\bindepend.py", line
351, in getAssemblies
res = GetManifestResources(pth)
File "c:\python27\lib\site-
packages\PyInstaller\utils\win32\winmanifest.py", line 1005, in
GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names,
languages)
File "c:\python27\lib\site-
packages\PyInstaller\utils\win32\winresource.py", line 168, in GetResources
hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
pywintypes.error: (1006, 'LoadLibraryEx', 'The volume for a file has been
externally altered so that the opened file is no longer valid.')
I have encountered the same issue. It was caused by Pyinstaller being very greedy when processing the files in the source directory, and as such it traversed and picked up things that were not suitable, e.g. subdirectories of frameworks, such as .git, or, in my case .vscode. This may results in some hard-to-debug issues - see https://stackoverflow.com/a/58195896/1603969.
I solved my problem by copying the source files to a clean directory and then producing a bundle from this clean directory where only necessary source files resided.

pyinstaller create binary from python3 file, error: AttributeError: 'NoneType' object has no attribute 'rfind'

I try to create python binary from python3 file with pyinstaller, but it failled and the error message as below, can anyone give me some suggestion? thanks.
user#user:~ /Pyinstaller3/pyinstaller-python3$ **python3.4 pyinstaller.py -F /home/austinlin/programTest/translate0918_1.py**
67 INFO: PyInstaller: 3.0.dev
67 INFO: Python: 3.4.3
67 INFO: Platform: Linux-3.2.0-90-generic-pae-i686-with-Ubuntu-12.04-precise
67 INFO: wrote /home/austinlin/tools/Pyinstaller3/pyinstaller-python3/translate0918_1/translate0918_1.spec
68 INFO: UPX is not available.
69 INFO: Extending PYTHONPATH with /home/austinlin/programTest
69 INFO: checking Analysis
76 INFO: checking PYZ
79 INFO: checking PKG
79 INFO: Building because toc changed
80 INFO: Building PKG (CArchive) out00-PKG.pkg
Traceback (most recent call last):
File "pyinstaller.py", line 18, in <module>
run()
File "/home/austinlin/tools/Pyinstaller3/pyinstaller-python3/PyInstaller/__main__.py", line 99, in run
run_build(opts, spec_file, pyi_config)
File "/home/austinlin/tools/Pyinstaller3/pyinstaller-python3/PyInstaller/__main__.py", line 47, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **opts.__dict__)
File "/home/austinlin/tools/Pyinstaller3/pyinstaller-python3/PyInstaller/building/build_main.py", line 734, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/home/austinlin/tools/Pyinstaller3/pyinstaller-python3/PyInstaller/building/build_main.py", line 677, in build
exec(text, spec_namespace)
File "<string>", line 28, in <module>
File "/home/austinlin/tools/Pyinstaller3/pyinstaller-python3/PyInstaller/building/api.py", line 421, in __init__
strip_binaries=self.strip, upx_binaries=self.upx,
File "/home/austinlin/tools/Pyinstaller3/pyinstaller-python3/PyInstaller/building/api.py", line 232, in __init__
self.__postinit__()
File "/home/austinlin/tools/Pyinstaller3/pyinstaller-python3/PyInstaller/building/datastruct.py", line 153, in __postinit__
self.assemble()
File "/home/austinlin/tools/Pyinstaller3/pyinstaller-python3/PyInstaller/building/api.py", line 300, in assemble
pylib_name = os.path.basename(bindepend.get_python_library_path())
File "/usr/lib/python3.4/posixpath.py", line 139, in basename
i = p.rfind(sep) + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
But if I use python python2.7 pyinstaller.py -F python2file.py, it work fine

Categories

Resources