0

I created an exe with pyinstaller (I'm using python 3.7.6 and pyinstaller 3.6) using

pyinstaller --onefile --icon=icon.ico my_script.py

(the problem is the same even with pyinstaller --onedir --icon=icon.ico my_script.py)

the exe is built fine, but I get multiple errors along the way:

25484 INFO: Excluding import 'PyQt5'
25486 INFO:   Removing import of PyQt5 from module PIL.ImageQt
25487 INFO: Import to be excluded not found: 'FixTk'
25488 INFO: Excluding import 'tkinter'
25490 INFO:   Removing import of tkinter from module PIL.ImageTk
25491 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
25496 INFO: Excluding import 'tkinter'
25498 INFO: Import to be excluded not found: 'FixTk'
25499 INFO: Loading module hook "hook-pkg_resources.py"...
26227 INFO: Processing pre-safe import module hook   win32com
26524 INFO: Excluding import '__main__'
26525 INFO:   Removing import of __main__ from module pkg_resources

despite of these errors, the exe works fine on some computers, and on some of them don't. Where it doesn't work I get this error at startup:

Traceback (most recent call last):
  File "my_script.py", line 39, in <module>
  File "c:\users\valerio\appdata\local\programs\python\python37-32\lib\site-pack
ages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
  File "site-packages\cv2\__init__.py", line 3, in <module>
ImportError: DLL load failed: The specified module could not be found.
[2800] Failed to execute script my_script

so my questions are:

  1. why am I getting the built errors?

  2. why on some computer is working fine and some dont's?? this second question is really driving me crazy..

thank you

5
  • PyInstaller is not cross platform - so if you compile on a (for example) Windows 10 64-bit machine and then try running on a Mac, Linux, or even Windows 32-bit it won't work properly, or at all. Commented Mar 28, 2020 at 18:38
  • @wstk i forgot to say that the other PCs are windows as well. Honestly I don't remember if they are 32 or 64 bit.. so what should I do to make it platform independent? Commented Mar 28, 2020 at 18:53
  • Unfortunately PyInstaller is just not cross platform. If you want to use the .exe on (say) MacOS, you need to compile it on MacOS. Commented Mar 28, 2020 at 19:20
  • ok but this problem happens on the same platform, so windows - windows. Of course I'm not expeting to use an EXE on a MacOs Commented Mar 29, 2020 at 9:36
  • Which windows versions are you using? Commented Mar 30, 2020 at 0:52

1 Answer 1

1

I found the answer to my problem. I write it here in case anyone needs it. the problem is just on windows server 2008 and 2012. They are missing a module called "desktop experience".

Once installed it (for example with this guide) the error will disappear.

Another similar discussion

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.