简体   繁体   中英

Autoit Pyinstaller OSError: Cannot load AutoItX from path: C:\Users\AppData\Local\Temp\_MEI74002\autoit\lib\AutoItX3_x64.dll

I'm trying to change my .py file to .exe however I get the above error when I try to run it. It seems to compile fine with Pyinstaller. I used pyinstaller filename.spec -F -i "pic.ico" my filename.spec is below I've tried several solutions on stackoverflow but can't seem to find the right one. It seems to think that the .dll file is in that directory however the _MEI74002 folder doesn't exist there. When I run filename.py it works perfectly. The actual path for the .dll file is in the datas variable. I don't understand why it's not checking in there.

a = Analysis(['Filename.py'],
         pathex=['Path\\To\\Python\\File'],
         binaries=[('C:\\Users\\PycharmProjects\\iProdi2\\chromedriver.exe', '.\\selenium\\webdriver')],
         datas=[('C:\\Users\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\site-packages\\autoit\\lib\\AutoItX3_x64.dll', '.')], #This is where my .dll file is actually stored
         hiddenimports=[],
         hookspath=[],
         runtime_hooks=[],
         excludes=[],
         win_no_prefer_redirects=False,
         win_private_assemblies=False,
         cipher=block_cipher,
         noarchive=False)

Edit: I want to distribute my program to other computers so I would like for the .dll file to be a part of the .exe application so the users don't have to download anything.

Edit2: I've got the below error when running the program after putting debug = True, strip=None, upx=True,console=True. I still don't understand what's wrong. I knew it was something wrong with the autoit library before but wasn't sure about how to resolve it.

File "filename.py", line 18, in <module>
from autoit import control_send
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 621, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\autoit\__init__.py", line 6, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 621, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\autoit\autoit.py", line 26, in <module>
OSError: Cannot load AutoItX from path: 
C:\Users\AppData\Local\Temp\_MEI179202\autoit\lib\AutoItX3_x64.dll
[22596] Failed to execute script filename

"OSError: Cannot load AutoItX from path:": Change '.' to 'autoit\\lib' – stovfl 31 mins ago

From my understanding the MEI... folder is a temporary folder and I was putting the .dll file into it by '.' when it should have been in the autoit\\lib subfolder. So all I had to do was what stovfl said to do above. Thanks for the help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM