Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have changed a shell launcher found at http://inasafe.linfiniti.com/html/id/developer-docs/platform_windows.html as to fit my wish: setting the system environment variables to be able to use PyQGIS modules from the default Python IDLE GUI. When I try to run the original version of the shell launcher it works, namely I succeed in importing (for instance) the "qgis.core" module, in DOS environment. When I launch my modified one (see below) the shell starts but the variables seem no to be set properly, as importing the module outputs the error:

ImportError: DLL load failed: Impossibile trovare il modulo specificato # (impossible to import the specified module)

My OS is Windows XP sp3, Python is 2.7.3 and QGIS is Lisboa v.1.8. Here's my personal SHELL LAUNCHER:

@echo off
SET OSGEO4W_ROOT=C:\QUANTU~1
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\Python27\Lib\idlelib\idle.pyw
@echo off
SET GDAL_DRIVER_PATH=%IDLE%\bin\gdalplugins\1.9
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-6.4.2\lib
path %PATH%;"%OSGEO4W_ROOT%\apps\Python27\Scripts\"

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

start "Quantum GIS Shell" /B "cmd.exe" %*

When I test whether if the variables are set properly, it seems they are, but still not succeeding in importing the modules.

import sys
for item in sys.path:
    print item

C:\Windows\System32
C:\Quantum_GIS_Lisboa\apps\Python27\Lib\idlelib
C:\Quantum_GIS_Lisboa\apps\qgis\python
C:\Windows\system32\python27.zip
C:\Quantum_GIS_Lisboa\apps\Python27\DLLs
C:\Quantum_GIS_Lisboa\apps\Python27\lib
C:\Quantum_GIS_Lisboa\apps\Python27\lib\plat-win
C:\Quantum_GIS_Lisboa\apps\Python27\lib\lib-tk
C:\Python27\ArcGIS10.1
C:\Quantum_GIS_Lisboa\apps\Python27
C:\Quantum_GIS_Lisboa\apps\Python27\lib\site-packages
C:\Quantum_GIS_Lisboa\apps\Python27\lib\site-packages\PIL
C:\Quantum_GIS_Lisboa\apps\Python27\lib\site-packages\win32
C:\Quantum_GIS_Lisboa\apps\Python27\lib\site-packages\win32\lib
C:\Quantum_GIS_Lisboa\apps\Python27\lib\site-packages\Pythonwin
C:\Quantum_GIS_Lisboa\apps\Python27\lib\site-packages\wx-2.8-msw-unicode
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Eventually I managed to have the personal shell launcher! The trick was to investigate the "o4w_env.bat" file in order to understand what the "call" at the second line actually does. So I tried and succeded with this:

  1. Copy the "idle.pyw" (or the IDE You'd like to use to the Quantum GIS main folder (in my case it was "C:/Quantum_GIS_Lisboa");
  2. Copy the SHELL LAUNCHER (see point 3) with extension ".bat" in "\bin";

  3. Run this SHELL LAUNCHER (simple double click):

    @echo off

    SET OSGEO4W_ROOT=C:\QUANTU~1

    call "%OSGEO4W_ROOT%"\bin\o4w_env.bat

    @echo off

    SET GDAL_DRIVER_PATH=%IDLE%\bin\gdalplugins\1.9 path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-6.4.2\lib path %PATH%;"%OSGEO4W_ROOT%\apps\Python27\Scripts\"

    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

    start "Quantum GIS Shell" /B "idle.pyw" %* # This is where You specify the IDE You want to use, mine is "idle.pyw", but if You copy another one (as in point 1), You should replace "idle.pyw" with ""

Hope this could help anybody. Cheers!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.