Monday, 20 November 2017

pyqgis - Which python version for standalone script with Qgis module


I'm writing a standalone python script, and I need to use Qgis module. For information i'm working on a Mac and I already have Qgis 2.18 installed. So in list of module importation, I wrote this :


import qgis


But when I run my script, it returns me :


No module named 'qgis'

I search where it comes from, and apparently, it's because I have many python versions installed. And I dont use the one who is connected to Qgis.


I check my python install with this command which -a python python3and it returns :


/opt/local/bin/python
/usr/bin/python
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/usr/local/bin/python3


According to python --version I'm using Python 3.4.7


Somebody can help me to use the good one ?



Answer



QGIS 2.18 uses python 2.7.


QGIS 3 will use python 3.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...