Python Forum

Full Version: converting py to exe
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,
I'm new here. I am a beginner. i wrote a program on python and i'd like to convert it to .exe but I get an error. Below is the error i get. How can i solve this problem? Thank you in advance.
pip version is 20.2.4
python version 3.8

Z:\BARKIN\python exercises>pyinstaller test.pyw
75 INFO: PyInstaller: 4.0
75 INFO: Python: 3.8.6
76 INFO: Platform: Windows-10-10.0.19041-SP0
2256 INFO: wrote Z:\BARKIN\python exercises\test.spec
2263 INFO: UPX is not available.
2312 INFO: Extending PYTHONPATH with paths
['Z:\\BARKIN\\python exercises', 'Z:\\BARKIN\\python exercises']
2651 INFO: checking Analysis
2653 INFO: Building Analysis because Analysis-00.toc is non existent
2653 INFO: Initializing module dependency graph...
2662 INFO: Caching module graph hooks...
2744 INFO: Analyzing base_library.zip ...
5793 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\bakca\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
5811 INFO: distutils: retargeting to non-venv dir 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\\lib'
7939 INFO: Caching module dependency graph...
8172 INFO: running Analysis Analysis-00.toc
Traceback (most recent call last):
File "C:\Users\bakca\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\bakca\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\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\win32ctypes\core\ctypes\_util.py", line 42, in check_null
raise make_error(function, function_name)
OSError: [WinError 1920] Das System kann auf die Datei nicht zugreifen.

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.1776.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.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "C:\Users\bakca\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\bakca\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\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 720, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Users\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 667, in build
exec(code, spec_namespace)
File "Z:\BARKIN\python exercises\test.spec", line 6, in <module>
a = Analysis(['test.pyw'],
File "C:\Users\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 242, in __init__
self.__postinit__()
File "C:\Users\bakca\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\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\building\build_main.py", line 390, in assemble
self.binaries.extend(bindepend.Dependencies([('', python, '')],
File "C:\Users\bakca\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\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 407, in getAssemblyFiles
for assembly in getAssemblies(pth):
File "C:\Users\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\depend\bindepend.py", line 358, in getAssemblies
res = GetManifestResources(pth)
File "C:\Users\bakca\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1000, in GetManifestResources
return winresource.GetResources(filename, [RT_MANIFEST], names, languages)
File "C:\Users\bakca\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\bakca\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.1776.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\bakca\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, 'LoadLibraryExW', 'Das System kann auf die Datei nicht zugreifen.')
Hey! It seems like error is telling that you need admin rights on your pc to access the file!
or
if you are admin and cannot try to go in properties by right click and then in attributes uncheck the read only option!

HOPE IT HELPS!
I have admin rights and the read only option is already unchecked. Still does'nt work.
(Oct-27-2020, 05:46 PM)Barkin Wrote: [ -> ]I have admin rights and the read only option is already unchecked. Still does'nt work.

Hmmm Then Try to run python in admin and then execute your scripts!
As mention this is a admin rights problem accessing files.
You do also use a Windows Store version of Python(this can also make trouble),think we had a post(pyinstaller) about this before.
So i would remove that version and use Python 3.8 (3.6-3.7) and pip installation under Windows.

Couple of advise.
Run cmd as Administrator.

Make a virtual environment(build into python venv) as posted here.
This is like new version of Python,and admin problem or other problem with install is usually gone using when using virtual environment.
Thank you. I've deleted python 3.8 and dowloaded 3.9 from python.org and run it as admin. It worked. It converted my py file to exe. But now when i click on my test.exe file i get this error "Failed to execute script test".
It may be that it to early for Python 3.9 and pyinstaller,i have not tested yet.
Requirements and Tested Platforms
pyinstaller Wrote:Python:
3.5-3.8

tinyaes 1.0+ (only if using bytecode encryption). Instead of installing tinyaes, pip install pyinstaller[encryption] instead.
Was the same in early stages when Python 3.8 came out,it tok some time before it did work official in pyinstaller.

Can try the development version,will have the earliest test support foe Python 3.9
pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
For now so early after Python 3.9 came out,it can be best to Python 3.8 in need to use pyinstaller.
After downloading
pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
it works now. Thank you.