1

I install QGIS via OSGeo4W 32 bit on windows 7 32 bit and i want to take PYQGIS API in standalone python script.

First I have python 3.5.2 and I have before install sip via pip and pyqt4 via gohlke booth successful.]]

After install QGIS via OSGeo4W and I create a qgis.pth file in python site-packages with the paths.

sys.path
['', 'C:\\Users\\usename\\AppData\\Local\\Programs\\Python\\Python35-32\\Lib\\idlelib', 'C:\\OSGeo4W\\apps\\qgis\\python', 'C:\\Users\\usename\\AppData\\Local\\Programs\\Python\\Python35-32\\python35.zip', 'C:\\Users\\usename\\AppData\\Local\\Programs\\Python\\Python35-32\\DLLs', 'C:\\Users\\usename\\AppData\\Local\\Programs\\Python\\Python35-32\\lib', 'C:\\Users\\usename\\AppData\\Local\\Programs\\Python\\Python35-32', 'C:\\Users\\usename\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\site-packages', 'C:\\OSGeo4W\\bin', 'C:\\OSGeo4W\\lib', 'C:\\OSGeo4W\\apps', 'C:\\OSGeo4W\\apps\\qgis\\bin', 'C:\\OSGeo4W\\apps\\qgis\\lib', 'C:\\OSGeo4W\\apps\\qgis\\qtplugins', 'C:\\OSGeo4W\\apps\\qgis\\python\\qgis', 'C:\\OSGeo4W\\apps\\qgis\\resources', 'C:\\OSGeo4W\\apps\\qgis\\plugins', 'C:\\OSGeo4W\\apps\\qgis\\grass\\bin', 'C:\\OSGeo4W\\apps\\qgis\\grass\\modules', 'C:\\OSGeo4W\\apps\\qgis\\grass\\scripts', 'C:\\OSGeo4W\\apps\\saga', 'C:\\OSGeo4W\\apps\\saga\\dll', 'C:\\OSGeo4W\\apps\\saga\\modules', 'C:\\OSGeo4W\\apps\\gdal', 'C:\\OSGeo4W\\apps\\gdal-dev\\bin', 'C:\\OSGeo4W\\apps\\grass\\grass-7.3.svn\\bin', 'C:\\OSGeo4W\\apps\\grass\\grass-7.3.svn\\etc\\python', 'C:\\OSGeo4W\\apps\\grass\\grass-7.3.svn\\etc\\python\\grass', 'C:\\OSGeo4W\\apps\\grass\\grass-7.3.svn\\lib', 'C:\\OSGeo4W\\apps\\grass\\grass-7.3.svn\\scripts', 'C:\\OSGeo4W\\apps\\Python25', 'C:\\OSGeo4W\\apps\\Python27']

but if i try to import qgis.core show me that error message :

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import qgis.core
  File "C:\OSGeo4W\apps\qgis\python\qgis\__init__.py", line 26, in <module>
    from qgis.PyQt import QtCore
  File "C:\OSGeo4W\apps\qgis\python\qgis\PyQt\QtCore.py", line 60, in <module>
    QPyNullVariant.__nonzero__ = MethodType(__nonzero__, None, QPyNullVariant)
TypeError: method expected 2 arguments, got 3

Any idea why ?

  • Your pth file is not correct and for the moment QGIS use exclusively Python 2.7.x and not Python 3.x – gene Jan 1 '17 at 16:23
  • that is the problem? – Chris Papas Jan 1 '17 at 19:55
  • how to fix that ? – Chris Papas Jan 1 '17 at 20:03
  • Using a Python 2.7. version. – gene Jan 1 '17 at 20:24
  • if i use Python 2.7. version then show me error no sip module name,and i cant to install sip package on python 2.7,i think so is only for python 3. – Chris Papas Jan 1 '17 at 20:30

Your Answer

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

Browse other questions tagged or ask your own question.