# Buggy code
def __init__(self, parent):
    """Constructor."""
    QTableView.__init__(self, parent)
    self.parent = parent
    self.setModel(parent.model())
    self.setFocusPolicy(Qt.NoFocus)
    self.verticalHeader().hide()
    if PYQT5:
        self.horizontalHeader().setSectionResizeMode(QHeaderView.Fixed)
    else:
        self.horizontalHeader().setResizeMode(QHeaderView.Fixed)

    parent.viewport().stackUnder(self)

    self.setSelectionModel(parent.selectionModel())
    for col in range(1, parent.model().columnCount()):
        self.setColumnHidden(col, True)

    self.setColumnWidth(0, parent.columnWidth(0))
    self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    self.show()

    self.setVerticalScrollMode(1)


# Traceback (Exception)
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/spyder/app/mainwindow.py", line 3001, in main
mainwindow = run_spyder(app, options, args)
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/spyder/app/mainwindow.py", line 2905, in run_spyder
main.setup()
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/spyder/app/mainwindow.py", line 869, in setup
self.projects = Projects(self)
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/spyder/plugins/projects.py", line 71, in init
self.setup_project(self.get_active_project_path())
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/spyder/widgets/projects/explorer.py", line 226, in setup_project
show_all=self.show_all)
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/spyder/widgets/explorer.py", line 195, in setup
self.common_actions = self.setup_common_actions()
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/spyder/widgets/projects/explorer.py", line 55, in setup_common_actions
self.toggle_hscrollbar(self.show_hscrollbar)
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/spyder/widgets/projects/explorer.py", line 70, in toggle_hscrollbar
self.header().setResizeMode(QHeaderView.ResizeToContents)
File "/home/developer/.virtualenvs/dev3/lib/python3.5/site-packages/qtpy/_patch/qheaderview.py", line 83, in setResizeMode
raise Exception('setResizeMode is only available in Qt4. Use '
Exception: setResizeMode is only available in Qt4. Use setSectionResizeMode instead.

# Fixed code
def __init__(self, parent):
    """Constructor."""
    QTableView.__init__(self, parent)
    self.parent = parent
    self.setModel(parent.model())
    self.setFocusPolicy(Qt.NoFocus)
    self.verticalHeader().hide()
    try:
        self.horizontalHeader().setSectionResizeMode(QHeaderView.Fixed)
    except:  # support for qtpy<1.2.0
        self.horizontalHeader().setResizeMode(QHeaderView.Fixed)

    parent.viewport().stackUnder(self)

    self.setSelectionModel(parent.selectionModel())
    for col in range(1, parent.model().columnCount()):
        self.setColumnHidden(col, True)

    self.setColumnWidth(0, parent.columnWidth(0))
    self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    self.show()

    self.setVerticalScrollMode(1)