Edit readme

This commit is contained in:
Alireza Adli 2023-12-14 13:59:00 -05:00
parent 26c4f2ca94
commit 1d46157571

View File

@ -10,28 +10,30 @@ To use PyQGIS without having the QGIS application run in the background, one nee
a. Go to the QGIS installation directorys Python folder. e.g. C:\Program Files\QGIS 3.34.1\apps\Python39
b. Duplicate the Python executable (python.exe) by copy-pasting it
c. Rename the duplicated version. E.g. pythonqgis.exe
c. Rename the duplicated version. e.g. pythonqgis.exe
3. Updating the Path variables
a. Go to Environmental Variables (from Windows start)
b. Click on Path and then click on Edit. Add the following paths:
> > i. C:\Program Files\QGIS 3.34.1\apps\Python39\pythonqgis
> > ii. C:\Program Files\QGIS 3.34.1\apps\Python39
> i. C:\Program Files\QGIS 3.34.1\apps\Python39\pythonqgis
> ii. C:\Program Files\QGIS 3.34.1\apps\Python39
c. Go back to the Environmental variables this time click on New and in New Variable box enter PYTHONPATH and in the Variable Value add the following paths (separate them with a colon). Some paths might be different. For example, apps\qgis can be apps\qgis-ltr.
i. C:\Program Files\QGIS 3.34.1\apps\qgis\python
ii. C:\Program Files\QGIS 3.34.1\apps\qgis\python\plugins
iii. C:\Program Files\QGIS 3.34.1\apps\Qt5\plugins
iv. C:\Program Files\QGIS 3.34.1\apps\gdal\share\gdal
v. Or altogether: C:\Program Files\QGIS 3.34.1\apps\qgis\python;C:\Program Files\QGIS 3.34.1\apps\qgis\python\plugins;C:\Program Files\QGIS 3.34.1\apps\Qt5\plugins;C:\Program Files\QGIS 3.34.1\apps\gdal\share\gdal
c. Go back to the Environmental variables this time click on New and in New Variable box enter PYTHONPATH and in the Variable Value add the following paths (separate them with a colon). Some paths might be different. For example, apps\qgis can be apps\qgis-ltr.
> i. C:\Program Files\QGIS 3.34.1\apps\qgis\python
> ii. C:\Program Files\QGIS 3.34.1\apps\qgis\python\plugins
> iii. C:\Program Files\QGIS 3.34.1\apps\Qt5\plugins
> iv. C:\Program Files\QGIS 3.34.1\apps\gdal\share\gdal
> v. Or altogether: C:\Program Files\QGIS 3.34.1\apps\qgis\python;C:\Program Files\QGIS 3.34.1\apps\qgis\python\plugins;C:\Program Files\QGIS 3.34.1\apps\Qt5\plugins;C:\Program Files\QGIS 3.34.1\apps\gdal\share\gdal
4. Validate importing qgis.core
a. Open a command prompt window
b. Enter pythonqgis
c. If the process has been done correctly, you wont face any error.
d. In the Python environment, import the package by:
i. Either import qgis.core
ii. Or from qgis.core import \*
d. In the Python environment, import the package by:
> i. Either import qgis.core
> ii. Or from qgis.core import \*