Specs
Python Version 3.9.6 (DL'd and installed from Python's website, not
Microsoft Store etc.)
Windows 10
Problem
I've tried to package python file in cmd using pyinstaller filename.py and pyinstaller --onefile Simple.py to *.exe which does not seem to work:
73 INFO: PyInstaller: 4.3 73 INFO: Python: 3.9.5 125 INFO: Platform:
Windows-10-10.0.19043-SP0 126 INFO: wrote
C:\Users\Baven\Desktop\Forexe\Simple.spec 186 INFO: UPX is available.
188 INFO: Extending PYTHONPATH with paths
['C:\Users\Baven\Desktop\Forexe',
'C:\Users\Baven\Desktop\Forexe'] 197 INFO: checking Analysis 197
INFO: Building Analysis because Analysis-00.toc is non existent 197
INFO: Initializing module dependency graph... 200 INFO: Caching module
graph hooks... 215 INFO: Analyzing base_library.zip ... 2561 INFO:
Processing pre-find module path hook distutils from
'C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\hooks\pre_find_module_path\hook-distutils.py'.
2561 INFO: distutils: retargeting to non-venv dir 'C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib'
4598 INFO: Caching module dependency graph... 4789 INFO: running
Analysis Analysis-00.toc Traceback (most recent call last): File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\pywintypes.py",
line 35, in pywin32error
yield File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\win32api.py",
line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\core\ctypes_util.py",
line 42, in check_null
raise make_error(function, function_name) OSError: [WinError 1920] The file cannot be accessed by the system.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 197, in run_module_as_main
return run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 87, in run_code
exec(code, run_globals) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\pyinstaller.exe_main.py",
line 7, in File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller_main.py",
line 114, in run
run_build(pyi_config, spec_file, **vars(args)) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller_main.py",
line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py",
line 737, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py",
line 684, in build
exec(code, spec_namespace) File "C:\Users\Baven\Desktop\Forexe\Simple.spec", line 7, in
a = Analysis(['Simple.py'], File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py",
line 242, in init
self.postinit() File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\datastruct.py",
line 160, in postinit
self.assemble() File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py",
line 391, in assemble
self.binaries.extend(bindepend.Dependencies([('', python, '')], File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py",
line 224, in Dependencies
for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects): File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py",
line 403, in getAssemblyFiles
for assembly in getAssemblies(pth): File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py",
line 354, in getAssemblies
res = GetManifestResources(pth) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\utils\win32\winmanifest.py",
line 1016, in GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names, languages) File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\utils\win32\winresource.py",
line 170, in GetResources
hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE) File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\win32api.py",
line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\contextlib.py",
line 135, in exit
self.gen.throw(type, value, traceback) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\pywintypes.py",
line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror) win32ctypes.pywin32.pywintypes.error: (1920,
'LoadLibraryExW', 'The file cannot be accessed by the system.')
C:\Users\Baven\Desktop\Forexe>pyinstaller --onefile Simple.py 72 INFO:
PyInstaller: 4.3 72 INFO: Python: 3.9.5 122 INFO: Platform:
Windows-10-10.0.19043-SP0 123 INFO: wrote
C:\Users\Baven\Desktop\Forexe\Simple.spec 166 INFO: UPX is available.
168 INFO: Extending PYTHONPATH with paths
['C:\Users\Baven\Desktop\Forexe',
'C:\Users\Baven\Desktop\Forexe'] 177 INFO: checking Analysis 177
INFO: Building Analysis because Analysis-00.toc is non existent 178
INFO: Initializing module dependency graph... 181 INFO: Caching module
graph hooks... 196 INFO: Analyzing base_library.zip ... 2579 INFO:
Processing pre-find module path hook distutils from
'C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\hooks\pre_find_module_path\hook-distutils.py'.
2580 INFO: distutils: retargeting to non-venv dir 'C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib'
4596 INFO: Caching module dependency graph... 4777 INFO: running
Analysis Analysis-00.toc Traceback (most recent call last): File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\pywintypes.py",
line 35, in pywin32error
yield File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\win32api.py",
line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\core\ctypes_util.py",
line 42, in check_null
raise make_error(function, function_name) OSError: [WinError 1920] The file cannot be accessed by the system.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 197, in run_module_as_main
return run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 87, in run_code
exec(code, run_globals) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\pyinstaller.exe_main.py",
line 7, in File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller_main.py",
line 114, in run
run_build(pyi_config, spec_file, **vars(args)) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller_main.py",
line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py",
line 737, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py",
line 684, in build
exec(code, spec_namespace) File "C:\Users\Baven\Desktop\Forexe\Simple.spec", line 7, in
a = Analysis(['Simple.py'], File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py",
line 242, in init
self.postinit() File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\datastruct.py",
line 160, in postinit
self.assemble() File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\building\build_main.py",
line 391, in assemble
self.binaries.extend(bindepend.Dependencies([('', python, '')], File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py",
line 224, in Dependencies
for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects): File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py",
line 403, in getAssemblyFiles
for assembly in getAssemblies(pth): File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\depend\bindepend.py",
line 354, in getAssemblies
res = GetManifestResources(pth) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\utils\win32\winmanifest.py",
line 1016, in GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names, languages) File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\PyInstaller\utils\win32\winresource.py",
line 170, in GetResources
hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE) File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\win32api.py",
line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\contextlib.py",
line 135, in exit
self.gen.throw(type, value, traceback) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32ctypes\pywin32\pywintypes.py",
line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror) win32ctypes.pywin32.pywintypes.error: (1920,
'LoadLibraryExW', 'The file cannot be accessed by the system.')
What I've also done and retried to package, all of which led to the outcome above (except the UPX)
Reinstalled
Restarted (also updated Windows)
Trying the conversion in virtual environment
Fixed the UPX (186 INFO: UPX is available.) by downloading and placing upx.exe in the *.py folder
Disabled (off) both (python & python3) App Installer in App execution aliases
What I find strange
Python version shown in cmd is still 3.9.5; also 3.9.5 in IDLE which changed to 3.9.6 after rebooting my PC
Other Python users can convert without issue
WindowsApps folder access returned none (e.g. return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",)
When manually accessing the WindowApps folder, the notification "You don't currently have permission to access this folder." is shown. If that is the root cause, anyway to allow Python to access it?
Here's the link to the python file and what was converted: https://drive.google.com/file/d/1L8vVEc4z6LYxgN6XHWwJlujVsicMgfMy/view
I have also tried the below code as a *.py file:
#!/usr/bin/python
import sqlite3
conn = sqlite3.connect('test.db')
print "Opened database successfully";
The below was the outcome:
Traceback (most recent call last): File
"C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mysql\connector\network.py",
line 574, in open_connection
self.sock.connect(sockaddr) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively
refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 197, in _run_module_as_main
return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 87, in run_code
exec(code, run_globals) File "c:\Users\Baven.vscode\extensions\ms-python.python-2021.6.944021595\pythonFiles\lib\python\debugpy_main.py",
line 45, in
cli.main() File "c:\Users\Baven.vscode\extensions\ms-python.python-2021.6.944021595\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py",
line 444, in main
run() File "c:\Users\Baven.vscode\extensions\ms-python.python-2021.6.944021595\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py",
line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("main")) File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 268, in run_path
return _run_module_code(code, init_globals, run_name, File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 97, in _run_module_code
_run_code(code, mod_globals, init_globals, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py",
line 87, in run_code
exec(code, run_globals) File "c:\Users\Baven\Desktop\demo_mysql_test.py", line 3, in
mydb = mysql.connector.connect( File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mysql\connector_init.py",
line 273, in connect
return MySQLConnection(*args, **kwargs) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mysql\connector\connection.py",
line 107, in init
self.connect(**kwargs) File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mysql\connector\abstracts.py",
line 1003, in connect
self._open_connection() File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mysql\connector\connection.py",
line 350, in _open_connection
self._socket.open_connection() File "C:\Users\Baven\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mysql\connector\network.py",
line 576, in open_connection
raise errors.InterfaceError( mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL
server on 'localhost:3306' (10061 No connection could be made because
the target machine actively refused it)
They (both pyinstaller and SQL) seem to be connected to one root cause.
This fixed the issue:
python3 -m pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
I was trying to convert my python program to a standalone executable file. However, after running pyinstaller, it runs into an error and doesn't output the file. This is the log:
60 INFO: PyInstaller: 3.6
60 INFO: Python: 3.8.3
60 INFO: Platform: Windows-10-10.0.18362-SP0
61 INFO: wrote C:\Users\username\Downloads\pip\test.spec
63 INFO: UPX is not available.
64 INFO: Extending PYTHONPATH with paths
['C:\\Users\\username\\Downloads\\pip', 'C:\\Users\\username\\Downloads\\pip']
64 INFO: checking Analysis
65 INFO: Building Analysis because Analysis-00.toc is non existent
65 INFO: Initializing module dependency graph...
67 INFO: Caching module graph hooks...
71 INFO: Analyzing base_library.zip ...
1900 INFO: Processing pre-find module path hook distutils
1900 INFO: distutils: retargeting to non-venv dir 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\\lib'
3116 INFO: Caching module dependency graph...
3200 INFO: running Analysis Analysis-00.toc
Traceback (most recent call last):
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
yield
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\core\cffi\_dll.py", line 23, in _LoadLibraryEx
result = check_null(
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\core\cffi\_util.py", line 81, in __call__
self._raise_error(function_name)
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\core\cffi\_util.py", line 92, in _raise_error
raise exception
OSError: [WinError 1920] The file cannot be accessed by the system
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\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\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 681, in build
exec(code, spec_namespace)
File "C:\Users\username\Downloads\pip\test.spec", line 6, in <module>
a = Analysis(['test.py'],
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 244, in __init__
self.__postinit__()
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 393, in assemble
self.binaries.extend(bindepend.Dependencies([('', python, '')],
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 228, in Dependencies
for ftocnm, fn in getAssemblyFiles(pth, manifest, redirects):
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 404, in getAssemblyFiles
for assembly in getAssemblies(pth):
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 355, in getAssemblies
res = GetManifestResources(pth)
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1007, in GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\utils\win32\winresource.py", line 170, in GetResources
hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
return _dll._LoadLibraryEx(fileName, 0, flags)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (1920, 'LoadLibraryEx', 'The file cannot be accessed by the system')
I also tried using brentvollebregt's auto-py-to-exe but ran into the same error.
Does it have to do with admin rights? Do I have to run command prompt as an admin in order to use pyinstaller? Or do I have to be logged-in as the admin?
Please use google before posting a question on stackoverflow, this is the original question: https://stackoverflow.com/a/60320831/12533273
You may have two versions of python3 installed and that's cousing a problem, try uninstalling all versions of python and then reinstalling them.
.\pyinstaller --onefile -w 'filename.py'
or
pyinstaller --onefile -w 'filename.py'
use the above two commands in the powershell while you went to the page of conversion should be made.
https://media.geeksforgeeks.org/wp-content/uploads/20200202204743/Screenshot-5013.png
I created my project with python 3.7. when I run 'pyinstaller --onefile -w dunamicGUI.py' command in terminal from /Users/mdarifulislam/Documents/GitHub/ZKProject/pythonServer/ directory it shows
40 INFO: PyInstaller: 3.5
40 INFO: Python: 2.7.16
47 INFO: Platform: Darwin-19.2.0-x86_64-i386-64bit
48 INFO: wrote /Users/mdarifulislam/Documents/GitHub/ZKProject/pythonServer/dunamicGUI.spec
54 INFO: UPX is not available.
Traceback (most recent call last):
File "/usr/local/bin/pyinstaller", line 10, in <module>
sys.exit(run())
File "/usr/local/lib/python2.7/site-packages/PyInstaller/__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "/usr/local/lib/python2.7/site-packages/PyInstaller/__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/usr/local/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/usr/local/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 791, in build
exec(code, spec_namespace)
File "/Users/mdarifulislam/Documents/GitHub/ZKProject/pythonServer/dunamicGUI.spec", line 17, in <module>
noarchive=False)
File "/usr/local/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 190, in __init__
raise ValueError("script '%s' not found" % script)
ValueError: script '/Users/mdarifulislam/Documents/GitHub/ZKProject/pythonServer/dunamicGUI.py' not found
Now what will be the solution.
Trying to figure out why Pyinstaller does not make the .EXE in the \Dist folder.
What i'm running is pyinstaller --onefile FileName.py
But after this it fails:
7758 INFO: Building PYZ (ZlibArchive) An error occurred, traceback follows:
Traceback (most recent call last):
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\auto_py_to_exe__main__.py", line 269, in convert
pyi.run() # Execute PyInstaller
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\marcu\appdata\local\programs\python\python38-32\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\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "C:\Users\Marcu\AppData\Local\Temp\tmp2gf7vp4s\File_Rename.spec", line 18, in
pyz = PYZ(a.pure, a.zipped_data,
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 98, in init
self.postinit()
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in postinit
self.assemble()
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble
self.code_dict = {
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 129, in
key: strip_paths_in_code(code)
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py", line 652, in strip_paths_in_code
consts = tuple(
File "c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py", line 653, in
strip_paths_in_code(const_co, new_filename)
File "c:\users\marcu\appdata\local\programs\python\python38-32\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)
And so on.
Path is set
Newest versions
Script is working as intended when run through Python
The idea is to make the .py an .exe so i can run it on a computer that does not have Python.
I Found the answer.
By using pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
it uninstalled the version 3.5 and installed the 4.0 dev version.
Used pyinstaller xxxx.py and voilĂ
Thank you for everyone's participation
I am trying to convert a python script to an exe file. I have added the python script to a folder together with pyinstaller, and I use the right PATH in CMD:
C:\Users\ola nordmann\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts\pyinstaller>pyinstaller --onefile CreatWordDoc.py
126 INFO: PyInstaller: 3.5
126 INFO: Python: 3.7.5
126 INFO: Platform: Windows-10-10.0.18362-SP0
127 INFO: wrote C:\Users\ola nordmann\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts\pyinstaller\CreatWordDoc.spec
132 INFO: UPX is not available.
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.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.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\ola nordmann\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts\pyinstaller\pyinstaller.exe\__main__.py", line 7, in <module>
File "C:\Users\ola nordmann\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\ola nordmann\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\ola nordmann\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\ola nordmann\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\ola nordmann\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts\pyinstaller\CreatWordDoc.spec", line 17, in <module>
noarchive=False)
File "C:\Users\ola nordmann\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PyInstaller\building\build_main.py", line 190, in __init__
raise ValueError("script '%s' not found" % script)
ValueError: script 'C:\Users\ola nordmann\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts\pyinstaller\CreatWordDoc.py' not found
This is what it shows.
I know there are some similar questions here, but I have not found a solution yet.
I found the solution. I had to first install Python from their own website instead of the Windows store. Then I had to add it to a PATH. After this it still did not work because I used Python 3.8.0, so I had to install pyinstaller development version.