[Qgis-user] How to set python search path for standalone script?

David Shi davidgshi at yahoo.co.uk
Wed May 4 05:07:51 PDT 2016


Hello, Jürgen
Thank you.
I am using QGIS in Windows.  Do I need to set paths?
Regards.
David 

    On Wednesday, 4 May 2016, 12:49, Jürgen E. Fischer <jef at norbit.de> wrote:
 

 Hi David,

On Wed, 04. May 2016 at 11:43:24 +0000, David Shi wrote:
> How to set python search path for standalone script?
> 
> I am writing a standalone script, but it can not import qgis.core and other processing.   modules.

In OSGeo4W there is a batch file python-qgis.bat you can pass your script to:

@echo off
call "%~dp0\o4w_env.bat"
@echo off
path %OSGEO4W_ROOT%\apps\qgis\bin;%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%\apps\qgis\qtplugins;%OSGEO4W_ROOT%\apps\qt4\plugins
set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python;%PYTHONPATH%
"%OSGEO4W_ROOT%"\bin\python.exe %*

PYTHONPATH and QGIS_PREFIX_PATH are most important.


Jürgen

-- 
Jürgen E. Fischer          norBIT GmbH            Tel. +49-4931-918175-31
Dipl.-Inf. (FH)            Rheinstraße 13          Fax. +49-4931-918175-50
Software Engineer          D-26506 Norden            http://www.norbit.de
QGIS release manager (PSC)  Germany                    IRC: jef on FreeNode                        
_______________________________________________
Qgis-user mailing list
Qgis-user at lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20160504/e63bda52/attachment.html>


More information about the Qgis-user mailing list