[Qgis-developer] How to set the PyQGIS environnement on Windows properly?

Nathan Woodrow madmanwoo at gmail.com
Tue May 5 15:16:53 PDT 2015


Hey,

This is what I use for everything that I have setup:

@ECHO OFF
REM
---------------------------------------------------------------------------------------
REM Change %OSGEO4W_ROOT% in setenv.bat to change in the location of QGIS.
REM
---------------------------------------------------------------------------------------


for %%x in (%cmdcmdline%) do if /i "%%~x"=="/c" set DOUBLECLICKED=1

REM Change OSGeo4W_ROOT to point to your install of QGIS.

SET OSGEO4W_ROOT=C:\OSGeo4W
SET QGISNAME=qgis
SET QGIS=%OSGEO4W_ROOT%\apps\%QGISNAME%
set QGIS_PREFIX_PATH=%QGIS%

CALL %OSGEO4W_ROOT%\bin\o4w_env.bat

: Python Setup
set PATH=%OSGEO4W_ROOT%\bin;%QGIS%\bin;%PATH%
SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python27
set PYTHONPATH=%QGIS%\python;%PYTHONPATH%

ECHO OSGeo path is: %OSGEO4W_ROOT%
ECHO Getting QGIS libs from: %QGIS%
ECHO Python loaded from: %PYTHONHOME%

Then you can add what you need at the end.  For a simple test just drop to
Python and try the import.

- Nathan

On Wed, 6 May 2015 at 07:42 Florin-Daniel Cioloboc <
cioloboc.florin at gmail.com> wrote:

> Hello everyone,
>
> I'm having problems with a specific error, which is pretty common from
> what I can see but can't seem to find a solution.
>
> When I try to import the qgis module the following error occurs:
>
> ImportError: No module named 'qgis'
>
> So far this is the guide <http://planet.qgis.org/planet/user/3/> I'm
> using and here's the settings for the .cmd, I'm assuming it has something
> to do with this:
>
>> @echo off
>> SET OSGEO4W_ROOT=D:\OSGeo4W64
>> call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
>> call "%OSGEO4W_ROOT%"\apps\grass\grass-6.4.3\etc\env.bat at echo off
>> path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
>> path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-6.4.3\lib
>>
>> set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python;
>> set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\Lib\site-packages
>> set QGIS_PREFIX_PATH=%OSGEO4W_ROOT%\apps\qgis
>> set PATH=C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.6\bin\pycharm.exe;%PATH%
>> cd %HOMEPATH%\TER\development
>> start "PyCharm aware of Quantum GIS" /B "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.6\bin\pycharm.exe" %*
>>
>> I realize this is quite a beginner's question but in any case I could use
> some help.
>
> Best wishes
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150505/c34b0d1f/attachment.html>


More information about the Qgis-developer mailing list