I got some code that I think should work, but I'm getting this error:

Traceback (most recent call last): File "", line 1, in File "c:/users/proxtr~1/appdata/local/temp/tmpgtrnqo.py", line 13, in qgis.path.insert(0, 'C:\Program Files\QGIS Essen\apps\qgis\python') AttributeError: 'module' object has no attribute 'path'

This is the code

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
from qgis.core import *
import os
import sys
from qgis.core import *
from PyQt4.QtGui import *

#""" Put your code here and remove the pass statement"""
#"Edit this path if you have a different version than QGIS 2.14.1"
qgis.path.insert(0, C:\Program Files\QGIS Essen\apps\qgis\python)
#The path is between these 2 comments"
app = QApplication([])
QgsApplication.setPrefixPath('/usr', True)
# Prepare processing framework 
from processing.core.Processing import Processing
from processing.tools import *

extent = layer.extent()
width, height = layer.width(), layer.height()
renderer = layer.renderer()
crs = layer.crs().toWkt()

layers = iface.layerTreeView().selectedLayers()

for layer in layers:
pipe = QgsRasterPipe()
file_writer = QgsRasterFileWriter(path)
| improve this question | | | | |
  • 1
    So, in your code you're importing 3 times anything from qgis.core? You're also mixing Windows and GNU/Linux paths, which, for sure, won't work. First give your code a review and then post a question. BTW, yo can just paste your code inside your question and click the button with curly brackets ("Code Sample") to format it. – Germán Carrillo Apr 14 '16 at 12:57

qgis module has no attribute path, I guess you wanted to do sys.path.insert()

So it should be:

sys.path.insert(0, 'C:\Program Files\QGIS Essen\apps\qgis\python')

Remember to pass your path as a string with " ".

| improve this answer | | | | |
  • Paths need forward slashes '/', '\\' escaping, or raw string notation r"" – user2856 Dec 17 '17 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.