code: def import_pyqt4(version=2):
      
      # The new-style string API (version=2) automatically
      # converts QStrings to Unicode Python strings. Also, automatically unpacks
      # QVariants to their underlying objects.
      import sip
  
      if version is not None:
          sip.setapi('QString', version)
          sip.setapi('QVariant', version)
  
      from PyQt4 import QtGui, QtCore, QtSvg
  
      if not check_version(QtCore.PYQT_VERSION_STR, '4.7'):
          raise ImportError("IPython requires PyQt4 >= 4.7, found %s" %
                            QtCore.PYQT_VERSION_STR)
  
      # Alias PyQt-specific functions for PySide compatibility.
      QtCore.Signal = QtCore.pyqtSignal
      QtCore.Slot = QtCore.pyqtSlot
  
      # query for the API version (in case version == None)
      version = sip.getapi('QString')
      api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT
      return QtCore, QtGui, QtSvg, api
docs: Import PyQt4
  
      Parameters
      ----------
      version : 1, 2, or None
        Which QString/QVariant API to use. Set to None to use the system
        default
  
      ImportErrors raised within this function are non-recoverable