I want to use PyCharm Community Edition 2019.3.1 to write Python based programs for QGIS on Windows 10 64bit. I installed QGIS (v.3.10.1) via the OSGeo4 Installer running with default settings. The implemented Python version is Python 3.7. I created a .cmd script to point on all necessary environments:
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\grass\grass78\etc\env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass78\lib
path %PATH%;%OSGEO4W_ROOT%\apps\Qt5\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Python37\Scripts
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%PYTHONHOME%;%OSGEO4W_ROOT%\apps\Python37
start "PyCharm aware of Quantum GIS" /B "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.1\bin\pycharm64.exe"
After running the script on a fresh installation of PyCharm, the programs opens but also show the error message:
"ImportError: DLL load failed: %1 is not a valid Win32 application."
After accepting this message (This error message didn't appear anymore if I repeating that step) I created a new Python script and set the missing interpreter on the Python version in the OSGEO4W folder. After updating the Python interpreter I want to import the qgis.core model via:
import qgis.core
but I get following error code:
Traceback (most recent call last):
File "C:/Users/[...]/PycharmProjects/untitled1/venv/aaa", line 1, in <module>
import qgis.core
File "C:\OSGEO4~1\apps\qgis\python\qgis\core\__init__.py", line 25, in <module>
from qgis._core import *
ImportError: DLL load failed: The specified module could not be found.
Process finished with exit code 1,
I'm wondering because the module inclusive functions appears in the auto completion and doesn't throw a error, but after writing the full statement the code greys out and mentioned error occurred.
As a Python newbie I would appreciate any help for my problem!