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.

First of all, I'm using Python 2.7.3, QGIS 1.8 (Lisboa) on Windows 7 pro 64 bits. Now let's go to the actual question:

I have written some code (Python) that works well within the QGIS built in Python console, but now I need to run it from outside QGIS (it is too much to ask for the final user to open QGIS, then the python console and to copy and paste the code).

I have been trying to access the QGIS API, but it is missing from my PYTHONPATH. I've tried whatever is on the instructions, plus a bunch of paths like: C:\Program Files(x86)\QGIS\apps\qgis\python\qgis and C:\Program Files(x86)\QGIS\apps\qgis\python. My result so far is always the same:

import qgis.core
ImportError: No module named qgis.core

Any ideas?

share|improve this question
I don't know if this is just a typo, but there should be a space between "Files" and "(x86)". Like so: C:\Program Files (x86) –  blah238 Nov 6 '12 at 0:10
add comment

1 Answer

It is possible that you have a separate Python installation on your system in addition to Python being bundled with QGIS and PyQGIS is installed only for the bundled Python.

Check if you have two separate Python installations and if you do, try running the script by specifying the full path to the Python executable under the QGIS installation. If that works you'd need to make sure that the PYTHONPATH and/or PATH variables first find the Python under QGIS, because (as far as I know) PATH is only checked until it encounters the first instance of whatever is being looked for...

share|improve this answer
add comment

Your Answer


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.