TransWikia.com

No Module named QGIS windows?

Geographic Information Systems Asked by NorthLand on November 12, 2020

I’ve been attempting to use the qgis module (QGIS version 3.14) in standalone scripting on a Windows 10 machine. However, I have found myself unable to import the qgis module. Code and message below:

import qgis 

returns

No module named 'qgis'

How do I either install qgis or find the appropriate python installation on my computer?

I’ve seen other versions of this question, however, they all seem to be for MacOS or Linux or I’ve attempted the provided solutions and had no results.

My attempts have generally been within the python window itself, not cmd or qgis console. And I’ve tried every installed version of python on my machine. even the one within the QGIS install folder.

EDIT: I’ve discovered within the bin of my QGIS install, python-qgis.bat. running this opens a python window that allows the import qgis to work.

BatchFile code

@echo off
call "%~dp0o4w_env.bat"
call qt5_env.bat
call py3_env.bat
@echo off
path %OSGEO4W_ROOT%appsqgisbin;%PATH%
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:=/%/apps/qgis
set GDAL_FILENAME_IS_UTF8=YES
rem Set VSI cache to be used as buffer, see #6448
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%appsqgisqtplugins;%OSGEO4W_ROOT%appsqt5plugins
set PYTHONPATH=%OSGEO4W_ROOT%appsqgispython;%PYTHONPATH%
"%PYTHONHOME%python" %*

My question now is, I typically run my python scripts via a batch file. Will I need to include this at the start of my own batch files. I don’t entirely understand what this file is doing.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP