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
6
  • can you please share your all import package names in ssl.py script Commented Jul 29, 2019 at 12:09
  • @shubham, I do not see the ssl.py file in the distribution folder, there is a _ssl.pyd one only. Commented Jul 29, 2019 at 12:19
  • can you tell me what are the packages you imported into the main.py Commented Jul 29, 2019 at 12:20
  • I use: sqlalchemy, pandas, datetime, smtplib Commented Jul 29, 2019 at 12:24
  • use pyinstaller 3.4, i think it may help you Commented Jul 29, 2019 at 12:32

1 Answer 1

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.

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

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.