Error loading python DLL - Access is denied when running PyInstaller onfile EXE

12 views
Skip to first unread message

Clayton Merkle

unread,
Apr 22, 2020, 10:05:38 AM4/22/20
to PyInstaller
Hello, I am currently trying to build a standalone executable for a PyQt5 GUI application on a Windows 10 machine. The executable builds and runs fine on the machine on which it was built, but when I move the exe file to another windows machine and attempt to run it, I get the following error: 

Error loading Python DLL
'C:\Users\CLAYTON.MERKLE\AppData\Local\Temp\_MEI143762\python37.dll
LoadLibrary: Access is denied.

The weird thing is I only receive this error when I try to run the exe file from certain directories. For example, I get this error if I run the exe from my Documents folder, but it runs just fine from the Desktop. However, when I sent the executable to a coworker, he received this error no matter where he ran it from. 

The machines that we use are enterprise machines with a lot of security measures, and we do not have administrator privileges, so that could be part of the problem, however once again on my machine the exe runs successfully from some directories which makes me think it may not be a permissions issue. I am building the executable with the following command:

pyinstaller --windowed --clean "PyFatigue.spec"

My .spec file is as follows:

# -*- mode: python -*-
import sys
sys.setrecursionlimit(5000)
import os
site_packages = next(p for p in sys.path if 'site-packages' in p)
block_cipher = None
a = Analysis(['PyFatigue.py'],
             pathex=[os.getcwd()],
             binaries=[],
             datas=[('PyFatigue.ui','.'),('sizeKnockdownDlg.ui','.'),('PyFatigue_rc.py','.'),('icons','icons')],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=['babel'],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
for d in a.datas:
    if '_C.cp37-win_amd64' in d[0]:
        a.datas.remove(d)
        break
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='PyFatigue',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=False,
          icon='icons/python-logo.ico' )

Please help me resolve this issue. Thank you. 

Reply all
Reply to author
Forward
0 new messages