I'm currently trying to translate the tasks I performed using Qgis (3.16.5) into a Python (Spyder) script, such that I will be able to perform these tasks on multiple files more easily.
However, I'm experiencing difficulties importing Qgis into Spyder. First, I received an error. After looking on internet, I found many topics related to this and I tried most of them.
Most of them were related to changing the PYTHONPATH and PATHs. I ended up with the script below: '''
@echo off
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
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python;
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\Lib\site-packages
cmd.exe
However, I now get a new error: "DLL load failed while importing _core: Cannot find procedure" and still cannot import qgis.core. I tried this code both with OSGeo4W64 and with a Qgis version downloaded without OSGeo4W64.
How can I import the Qgis.core?