3

I'm trying to distribute an executable file of a Python program I've created. For this purpose I'm using PyInstaller .

I use Windows 7 Professional with Python 3.7 The program runs successfully when inside PyCharm and produces the expected results.

As described in the PyInstaller manuals I've created the dist folder with:

pyinstaller main.py

The log output specifies that the process finished successfully.

When trying to run the main.exe from the distribution folder, the below error is produced:

Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\rthooks\pyi_rth_certifi.py", line 11, i
n <module>
  File "c:\users\tim\anaconda3\envs\timtf2_37\lib\site-packages\PyInstaller\load
er\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "ssl.py", line 98, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
[6236] Failed to execute script pyi_rth_certifi
Tim Mironov
  • 849
  • 8
  • 22

1 Answers1

4

So after a couple of hours, I managed to solve the problem. I did several things and still unsure what was the actuall fix, but this is the step-by-step flow I've done:

  1. Created a new environment using Anaconda. I've downgraded the Python version to 3.6.8, since I saw mentions of several compatibility problems with Python 3.7
  2. Installed all the requirements from my project, using Anaconda, since some mention problems due to mixed usage of pip and conda.
  3. Installed the latest version of pyinstaller.
  4. Activated the new environment and run pyinstaller from within it on the main.py script of the program with --hidden-import pyodbc argument.

That's it, now the distibuted program works on all Windows computers in the office.

Tim Mironov
  • 849
  • 8
  • 22
  • thanks, I have the same issue with 3.7.4, sovled with 3.6.10, and another unexpected surprise, the size of exe generated with 3.7.4 is 80+MB, but 30+MB with 3.6.10 – xiaoming Apr 11 '20 at 01:46