【问题标题】:Python3.2 PyQt4 installation: UnboundLocalErrorPython3.2 PyQt4安装:UnboundLocalError
【发布时间】:2011-11-06 15:59:46
【问题描述】:

最近我将我的 Ubuntu 升级到 11.10 版,所以我不得不重新安装 python3 模块。我下载了最新的 PyQt4,但是当我运行 configure.py 时出现以下错误:

    Qt Designer plugin disabled because Python library couldn't be found
An internal error occured.  Please report all the output from the program,
including the following traceback, to support@riverbankcomputing.com.
Traceback (most recent call last):
  File "configure.py", line 2269, in <module>
    main()
  File "configure.py", line 2254, in main
    subdirs=pyqt.qpy_libs() + pyqt_modules + xtra_modules + pyqt.tools(),
  File "configure.py", line 957, in tools
    link = "%s -lpython%d.%d%s" % (lib_dir_flag, py_major, py_minor, abi)
UnboundLocalError: local variable 'lib_dir_flag' referenced before assignment

我真的不知道出了什么问题。顺便提一句。在我将 Ubuntu 升级到 11.10 之前,我使用了 python3.1,一切都很好。

【问题讨论】:

    标签: python-3.x pyqt4 python-3.2


    【解决方案1】:

    在尝试构建 PyQt4 之前,请确保安装了正确的 sip 包。对于 ubuntu,我认为您将需要 python-sip-devpython3-sip-dev 包(以及任何依赖项)。或者,您可以从源代码下载并构建 latest version of sip

    当您为 pyqt 或 sip 运行 configure.py 脚本时,您必须使用正确版本的 python,例如:

    /usr/bin/python3.2 configure.py
    

    【讨论】: