I have installed **QGIS** via **osgeo4w** 32 bit yesterday, to take pyqgis api in standalone script, but I have some problems.

I have python 2.7.13 32bit and pyqt4 installed from Gohlke. After, I created a file (qgis.pth) and I put it in `python27/Lib/site-packages` to get the path for QGIS api.

Paths are :

    C:\OSGeo4W\apps\Python27
    C:\OSGeo4W\apps\Python27\libs
    C:\OSGeo4W\apps\Python27\Lib
    C:\OSGeo4W\apps\Python27\DLLs
    C:\OSGeo4W\apps\qgis\bin
    C:\OSGeo4W\apps\qgis\grass\bin
    C:\OSGeo4W\apps\qgis\grass\modules
    C:\OSGeo4W\apps\qgis\grass\scripts
    C:\OSGeo4W\apps\qgis\i18n
    C:\OSGeo4W\apps\qgis\python
    C:\OSGeo4W\apps\qgis\python\console
    C:\OSGeo4W\apps\qgis\resources
    C:\OSGeo4W\bin
    C:\OSGeo4W\bin\gdalplugins
    C:\OSGeo4W\bin\osgPlugins-3.1.7
    C:\OSGeo4W\etc\ini
    C:\OSGeo4W\etc\postinstall
    C:\OSGeo4W\etc\preremove
    C:\OSGeo4W\include\geos
    C:\OSGeo4W\lib

(and if I add the paths from QGIS pyqt4 and sip I had some errors)

The problems are:

First test :

    import qgis.core

Error :

    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 38, in <module>
        from PyQt4.QtCore import QPyNullVariant
    ImportError: cannot import name QPyNullVariant


Second test :

    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    #from PyQt4.QtSvg import *
    #from PyQt4.QtCore import pyqtSignal as Signal
    #from PyQt4.QtCore import pyqtSlot as Slot
    import qgis.core

error :

    sip.setapi(api, 1)
    ValueError: API 'QDate' has already been set to version 2

and finally, I tried this code :

    import sip
    API_NAMES = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"]
    API_VERSION = 2
    for name in API_NAMES:
        sip.setapi(name, API_VERSION)
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    from PyQt4.QtSvg import *
    from PyQt4.QtCore import pyqtSignal as Signal
    from PyQt4.QtCore import pyqtSlot as Slot
    import qgis.core

error if version is 1:

    from PyQt4.QtCore import QPyNullVariant
    ImportError: cannot import name QPyNullVariant

error if version is 2:

    from PyQt4.QtCore import QPyNullVariant
    ImportError: cannot import name QPyNullVariant

Any idea? If I remove the import for QGIS then I don't take some error with imports for sip ot pyqt. It's only if I try to import PyQGIS.