Search code examples
exepython-3.7importerrorcx-freezeshiboken2

Shiboken2 ... ImportError: DLL load failed: The specified procedure could not be found


I've recently been running into a Import Error from Shiboken2 that I didn't have before with my executable. I have an application that I built in PyCharm and I build an .exe for it with CX_Freeze. I have tried every single latest version of Python but I am 100% confident now that it's not the version of Python I have that is the issue. Especially, since the app run's perfectly when I run the source code, but when I use my Setup.py script to build it, I keep getting the following issue when I try to run it: enter image description here

Here is how my Setup.py script looks:

import sys
import os
from cx_Freeze import setup, Executable

sys.path.append(os.path.abspath("./src/"))
sys.path.append(os.path.abspath("./src/gui/rc/"))
sys.path.append(os.path.abspath("./database/component_actions"))


# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = {
    "packages": [
                # Facile sub-packages
                 "src.gui",
                 "src.qt_models",
                 "src.data",
                 "src.libs",
                 "src.tguiil",
                 "src.graphics",
                 "src.tools",
                 ],

    "includes": ["scipy.sparse.csgraph._validation",
                 "scipy.ndimage._ni_support",
                 "scipy._distributor_init",
                 ],

    "include_files": ["database/",
                      "src/tguiil/",
                      "src/data/"
                      ],

    "excludes": ["scipy.spatial.cKDTree",
                 ]
}

installOptions = {"skip_build":True}

base = None

# Uncomment for GUI applications to NOT show cmd window while running.
if sys.platform =='win32':
    base = 'Win32GUI'

executables = [
    Executable(script = 'src/facile.py', base=base, targetName = 'facile.exe', icon = 'resources/facade_logo_256.ico')
]

setup(name='***',
      version = '***',
      description = '***',
      options = {
          "build_exe": buildOptions,
          "install_exe": installOptions,
      },
      executables = executables)

(Sorry there's some info I am trying to remain hidden so that's why I use ***)

When the Problem started: I updated Shiboken 2 to version 5.15.0 but I was aware that I needed to update Pyside2 so I don't understand how this updated packages effects my executable build.

If need be I can show all my dependencies but I don't think that's the issue because as I said before the source code works properly when I run it on PyCharm, only when I build the executable and try to run it do I have this issue. Maybe this is a PATH issue? Or some dependency I need to include in the setup.py? B.T.W. I am using a Virtual Environment with Python 3.7.4 32-bit as the interpreter.


Solution

  • I believe this issue stemmed from my environment. I don't really have an adamant answer because I did multitude of things such as the following in this order:

    1. Downloaded PyCharm 2020 and deleted PyCharm 2019.
    2. Deleted all my past Python packages/executables/dependencies, deleted my old virtual environment, and old build folder.
    3. Reinstalled Python 3.7.4 and checked the PATH tab.
    4. Added a Python Interpreter with the Python 3.7.4 in virtual environment through PyCharm 2020's IDE.
    5. Pip installed all necessary dependencies from my requirements.txt.

    I made sure to give PyCharm enough time to think (load) in between each step and once I was finished I built the executable and it ran correctly.

    I hope this helps anyone who runs into a similar problem.