How to import qgis.core to Python app?

You have to verify two things :

PYTHONPATH

The PYTHONPATH is set for the cmd you launch. This means that you have to set it globally on your system

Go to Control Panel -> System-> Advanced.

Click on the 'Environment Variables' button.

In the 'System Variables' panel that appears, click New and enter PYTHONPATH in the 'Variable Name' field. In the 'Variable Value' field enter the path to QGIS.

Or you can set it directly on the cmd command line just before launching the python interpreter with :

set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib

PATH

The DLL which will be used by the qgis python module must be in your path. Just as you set the PYTHONPATH above, set the PATH environment variable so that it contains the directory where qgis_core.dll is located.

The directory to add is probably D:\Program Files (x86)\Quantum GIS Wroclaw\apps\qgis But check that qgis_core.dll is really there.

OSGEO4W

As was suggested in another answer, OSGEO4W install and sets everything up for you. It will install another Python though, which can complicate things when you want to install third party Python modules not available in OSGEO4W.

You would as well get the latest QGIS version too, which is 1.7.4 (1.8 coming soon).


Reinstall QGIS with OSGeo4W installer, it has everything you need to develop already set up. http://trac.osgeo.org/osgeo4w/

Tags:

Python

Qgis