Opened 13 years ago

Closed 13 years ago

#208 closed defect (worksforme)

OSGeo4w shell: Environment not set correctly to use python with qgis bindings

Reported by: milovanderlinden Owned by: osgeo4w-dev@…
Priority: major Component: Installer
Version: Keywords: install shell qgis python
Cc:

Description

Reproduce:

  1. run installer from scratch on a fresh windows xp sp2 virtual machine
  2. Select advanced install
  3. check qgis, qgis-grass-plugin and "shell: OSGeo4w Command shell"
  4. Install
  5. Start shell by double clicking OSGeo4w shell icon on desktop
  6. >python
  7. >>>import qgis.core

You will be told qgis.core cannot be found.

External links: http://desktopgisbook.com/Creating_a_Standalone_GIS_Application_1

Change History (2)

comment:1 by milovanderlinden, 13 years ago

Solution I took:

  1. Add a qgis.bat file in the directory: %OSGEO4W_ROOT%\etc\ini
  1. Put this as content in the file:

SET PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python PATH=C:\OSGeo4W\apps\qgis\bin;%PATH%

in reply to:  1 comment:2 by jef, 13 years ago

Resolution: worksforme
Status: newclosed

Replying to milovanderlinden:

Solution I took:

  1. Add a qgis.bat file in the directory: %OSGEO4W_ROOT%\etc\ini
  1. Put this as content in the file:

SET PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python PATH=C:\OSGeo4W\apps\qgis\bin;%PATH%

A better option would be to create a batch file like qgis.bat to start the application that is using qgis.core. Adding a qgis.bat to etc/ini might interfere with install of multiple qgis versions.

Note: See TracTickets for help on using tickets.