通过带有`--with-python3`的自制软件安装pyqt,但仍然转到Python 2

时间:2014-01-06 18:16:02

标签: python-3.x pyqt homebrew

这是我的命令和输出(省略了一些命令行参数)。出了什么问题?谢谢。

$ brew reinstall pyqt --with-python3
==> Reinstalling pyqt --with-python3
==> Downloading http://downloads.sf.net/project/pyqt/PyQt4/PyQt-4.10.3/PyQt-mac-
Already downloaded: /Library/Caches/Homebrew/pyqt-4.10.3.tar.gz
==> Patching
patching file configure.py
==> python configure.py --confirm-license --bindir=/usr/local/Cellar/pyqt/4.10.3
==> python ./configure-ng.py --confirm-license --bindir=/usr/local/Cellar/pyqt/4
==> make
==> make install
==> Caveats
Set PYTHONPATH if you want Python to find your site-packages:
  export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
==> Summary
  /usr/local/Cellar/pyqt/4.10.3: 560 files, 18M, built in 6.6 minutes

更新: 我认为pyqt的公式以某种方式硬编码python的版本。例如,它明确包含python2.7/site-packages/之类的路径。这是文件的一部分:

  def install
    # On Mavericks we want to target libc++, this requires a non default qt makespec
    if ENV.compiler == :clang and MacOS.version >= :mavericks
      ENV.append "QMAKESPEC", "unsupported/macx-clang-libc++"
    end

    args = [ "--confirm-license",
             "--bindir=#{bin}",
             "--destdir=#{lib}/python2.7/site-packages",
             "--sipdir=#{share}/sip" ]
    # We need to run "configure.py" so that pyqtconfig.py is generated, which
    # is needed by PyQWT (and many other PyQt interoperable implementations such
    # as the ROS GUI libs). This file is currently needed for generating build
    # files appropriate for the qmake spec that was used to build Qt. This method
    # is deprecated and will be removed with SIP v5, so we do the actual compile
    # using the newer configure-ng.py as recommended.
    system "python", "configure.py", *args
    (lib/'python2.7/site-packages').install 'pyqtconfig.py'

    # On Mavericks we want to target libc++, this requires a non default qt makespec
    if ENV.compiler == :clang and MacOS.version >= :mavericks
      args << "--spec" << "unsupported/macx-clang-libc++"
    end

    system "python", "./configure-ng.py", *args
    system "make"
    system "make", "install"
  end

1 个答案:

答案 0 :(得分:4)

你应该在Homebrew的git上查看这个问题: https://github.com/Homebrew/homebrew/issues/25735

我们不能再使用带有pyside / pyqt / sip的--with-python3参数。不幸的是,似乎我们暂时不能将Homebrew用于这些模块。他们可能必须找到另一个处理公式的解决方案,以便首先安装Python 2.7和Python3。

我摸不着头几天搞清楚了。最后从源代码安装PyQt。

祝你好运。