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'm trying to set the PYTHONPATH in order to be able to load the qgis classes in a python console (not the QGIS Python one).

I followed some resources I've found (PYQGIS Cookbook, and others) but I get still the same error message:

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

I'm pretty sure the problem is that I have a compiled version of QGIS and of course the PATHs suggested are different.

The folder of my QGIS is:

/home/user/QGIS-master

I tried to add the following to the .bashrc file in order to have the PATH but nothing changed (still the error of above):

export PYTHONPATH=/home/user/QGIS-master/python/

Someone has an idea of which is the correct PATH I have to export?

Thanks

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The folder for the PYTHONPATH must be the compiled one and not the source one. Your build path should be something like /home/user/QGIS-master/<builddir>/output/. I am guessing you are running from build your QGIS version so you just export the environment var like:

export PYTHONPATH=/home/user/QGIS-master/<builddir>/output/python/

maybe it also could be necessary to set LD_LIBRARY_PATH (as mentioned in PyQGIS Cookbook).

export LD_LIBRARY_PATH=/home/user/QGIS-master/<builddir>/output/lib/

share|improve this answer
    
Thanks for the clarification! It works now! –  matteo Jun 29 at 11:26

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.