I have a working standalone pyqgis program with mapping ability, it was in python 2.7 and qgis 2.x library. I used pyinstaller to package it up. Now I have migrated this application to python 3.6 and qgis 3.2.1-Bonn and pyqt 5.9. It is working fine in the PyCharm environment, the map is working, basically, qgis imports are working, such as:
from qgis.core import QgsApplication, QgsVectorLayer
I tried to package it up with pyinstaller 3.3.1 (as I have done successfully for the python 2.7 version of the program), it can get all of the qgis pyd/dlls into the package and the Qt GUI is running, it just keeps failing the qgis import statements such as above. The whole package is gathered into the C:\dist\qgis_test\ folder that contains the following qgis libs:
qgis._core.pyd
qgis._gui.pyd
qgis_core.dll
qgis_gui.dll
qgis_native.dll
When running the packaged executable file, it always bombs at the point of importing modules from the qgis.core or qgis.gui packages as shown below:
PYIMOD03: fullname=qgis._gui
PYIMOD03: filename=C:\dist\qgis_test\qgis._gui.pyd
PYIMOD03: fullname=qgis._core
PYIMOD03: filename=C:\dist\qgis_test\qgis._core.pyd
Traceback (most recent call last):
File "qgis_test.py", line 4, in <module>
from qgis.core import QgsApplication, QgsVectorLayer, QgsProject
File "C:\OSGeo4W64\apps\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "qgis\core\__init__.py", line 27, in <module>
File "C:\OSGeo4W64\apps\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 716, in load_module
module = loader.load_module(fullname)
ImportError: DLL load failed: The specified procedure could not be found.
The thing is that all of the PyQt5 libraries are all imported without error.
I've already set the following environmental variables to the package root directory (because that's where qgis_core.dll and qgis_gui.dll are located) like I did for the python 2 package:
QGIS, QGIS_PREFIX_PATH, PATH, PYTHONPATH, QT_PLUGIN_PATH
I pretty much searched and read up all python3 qgis related threads here and via google, but not much information is out there. Also, I noticed that the Qt plugins are under PyQt5\Qt\plugins within the package directory, I also set the environment variables accordingly to that, but still no luck. It keeps failing on those qgis import statements.