Hi Luke,

it looks like your QGISenv.bat does not add the QGIS internal plugin folder to the PYTHONPATH.

You may use something like:

set PYTHONPATH=^
%OSGEO4W_ROOT%\apps\%QGIS_ENV%\python;^
%OSGEO4W_ROOT%\apps\%QGIS_ENV%\python\plugins;^
%PYTHONPATH%

where OSGEO4W_ROOT is the path to where your QGIS is installed, and QGIS_ENV the release type, e.g. "qgis" or "qgis-ltr"

Greetings, Benjamin


Am 13/07/2022 um 03:54 schrieb Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer:
I have the need to launch QGIS from a python file due to some other checks I 
need to setup before it is running.  I convert this python file to an exe but 
Windows Defender flags it as a virus.  The exe is created from a batch (.cmd) 
file with the following calls:

call "QGISenv.bat"
call "python3.exe  jcms_authenticate.py"

The jcms_authenticate.py file is what launches QGIS using a python Popen 
method.  I used bat2exe converter to convert my CMD file to an exe.

I came across another method to convert python directly to an exe using 
pyinstaller but have had issues as mentioned  in the link below.  I am not 
using QGIS 3.4.4 but QGIS 3.16.16 and assume there is still the issue as I 
cannot successfully get the exe to work as I get the error:

Traceback (most recent call last):
   File "jcms_authenticate.py", line 7, in <module>
     from qgis.core import QgsApplication
ModuleNotFoundError: No module named 'qgis'
[37080] Failed to execute script 'jcms_authenticate' due to unhandled exception!

https://issues.qgis.org/issues/21341
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

--
Benjamin Jakimow, Doctoral Researcher
Earth Observation Lab | Geography Department | Humboldt-Universität zu Berlin

e-mail: [email protected]

phone:  +49 (0) 30 2093 6846
mobile: +49 (0) 157 5656 8477
fax:    +49 (0) 30 2093 6848
mail:   Unter den Linden 6 | 10099 Berlin | Germany
room: 2'211
web:    https://hu-berlin.de/eo-lab

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
  • [QGIS-Developer] Py... Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer
    • Re: [QGIS-Deve... Benjamin Jakimow via QGIS-Developer

Reply via email to