【问题标题】:How to install PyQt4 in anaconda?如何在 anaconda 中安装 PyQt4?
【发布时间】:2014-03-05 11:10:10
【问题描述】:

从 PyQt4 网站上,他们安装软件包的说明是下载 tarball 并使用配置文件。我有两个版本的 Python,一个是我的普通系统,另一个在 anaconda 内。我不确定如何将其安装在 anaconda 中。有没有安装 PyQt4 的 conda 命令?

【问题讨论】:

  • 你使用的是什么操作系统?
  • 很遗憾,除了等待之外,我没有给你一个好的答案。我们(Continuum)正在努力构建 PyQT,但不幸的是,这非常困难,尤其是在 OS X 上。
  • 我今天尝试从源代码构建并遇到此错误安装 SIP:Error: SIP requires Python to be built as a framework。我使用的是 miniconda,而不是完整的 Anaconda,但我认为它会遇到同样的问题。至少目前看来,用 Anaconda 安装 PyQt4 的事情看起来很没有希望。

标签: python pyqt pyqt4 anaconda


【解决方案1】:

使用自制软件在 OSX 上成功安装:

brew install sip
brew install pyqt     

它(当前)安装 PyQt4。 Anaconda是机器上的主要python(OSX 10.8.5)。

【讨论】:

  • 仅供参考:conda install pyqtconda install qt 此刻在 osx 上安装 qt4。我想它并没有赶上 linux... (:
【解决方案2】:

仅供参考

PyQt 现在可通过 conda 在所有平台上使用!
使用conda install pyqt 为Qt 框架获取这些#Python 绑定。 @ 下午 1:02 - 2014 年 5 月 1 日

https://twitter.com/ContinuumIO/status/461958764451880960

【讨论】:

  • 问题是现在,除非您特别要求,否则 conda 安装的是版本 5 而不是版本 4。
【解决方案3】:

看起来最新版本的 anaconda 强制在任何 pyqt 构建上安装 pyqt5.6,这对您的应用程序来说是致命的。在终端中,尝试:

conda install -c anaconda pyqt=4.11.4

它会提示降级 conda 客户端。之后应该就好了。

更新: 如果您想知道可以安装哪些 pyqt 版本,请尝试:

conda search pyqt

更新: 最新版本的 conda 安装了 anaconda-navigator。这取决于qt5,应该先去掉:

conda uninstall anaconda-navigator

然后安装“最新”的qt4:

conda install qt=4

【讨论】:

  • 你在哪个平台上?此时在 osx 上,capitan conda install pyqt 正在安装 4.11。也许 osx 有点落后;0
  • 我在 Windows/Linux.. 如果你想知道哪些 pyqt 版本可以安装,试试:conda search pyqt
  • 在我的系统中,conda search pyqt 仅列出了最新版本的 PyQt5(5.6.0 及更高版本)。我必须去另一个频道找到旧版本:conda search -c anaconda pyqt
【解决方案4】:

@Alaaedeen's answer 的更新版本。您可以指定要安装的任何软件包版本的任何部分。这可能会导致其他软件包版本发生变化。例如,如果您不关心您想要哪个特定版本的 PyQt4,请执行以下操作:

conda install pyqt=4

这将安装 PyQt 4 的最新次要版本和发行版。您可以指定所需版本的任何部分,而不仅仅是主要编号。所以,例如

conda install pyqt=4.11

将安装 4.11 版的最新(或最后一个)版本。

请记住,安装不同版本的包可能会导致依赖它的其他包前滚或回滚到它们支持您想要的版本的位置。

【讨论】:

  • 这等于conda install pyqt=4.11.4 吗?
  • @VibhuthaKumarage 不完全是。 pyqt=4.11.4 将完全安装版本 4.11.4。 pyqt=4 将安装最新的版本 4 的任何次要版本,不一定是 4.11.1。同样,您可以通过pyqt=4.11 修复主要和次要版本,但获取最新的 4.11 版本。
  • 不能用 Python 3.6.1 做到这一点 :(
  • @O.rka。我相信它很快就会上市
  • @user1556435 你可以做conda create -n py35 python=3.5 pyqt=4。您可以在初始命令行上列出所有包。
【解决方案5】:

如何在 Windows 上的 anaconda python 2 上安装 PyQt4:

起初我尝试通过pip install 安装 pyqt4:

C:\Users\myuser\Anaconda2\Scripts\pip.exe search pyqt4 > pyqt4.txt

它显示:

PyQt4 (4.11.4) - Python bindings for the Qt cross platform GUI toolkit

但是当我尝试安装时,它给出了一个错误:

C:\Users\myuser\Anaconda2\Scripts\pip.exe install PyQt4
Collecting PyQt4
  Could not find a version that satisfies the requirement PyQt4 (from versions:
)
No matching distribution found for PyQt4

似乎这个答案与这个问题有关: https://superuser.com/a/725869/213959

然后我尝试通过conda installHow to install PyQt4 in anaconda?)安装它:

C:\Users\myuser\Anaconda2\Scripts\conda.exe search pyqt

它显示:

pyqt                         4.10.4                   py26_0  defaults        
                             4.10.4                   py27_0  defaults        
                             4.10.4                   py33_0  defaults        
                             4.10.4                   py34_0  defaults        
                             4.10.4                   py26_1  defaults        
                             4.10.4                   py27_1  defaults        
                             4.10.4                   py33_1  defaults        
                             4.10.4                   py34_1  defaults        
                             4.11.4                   py27_0  defaults        
                             4.11.4                   py35_0  defaults        
                             4.11.4                   py27_2  defaults        
                             4.11.4                   py34_2  defaults        
                             4.11.4                   py35_2  defaults        
                             4.11.4                   py27_3  defaults        
                             4.11.4                   py34_3  defaults        
                             4.11.4                   py35_3  defaults        
                             4.11.4                   py27_4  defaults        
                             4.11.4                   py34_4  defaults        
                             4.11.4                   py35_4  defaults        
                             4.11.4                   py27_5  defaults        
                             4.11.4                   py34_5  defaults        
                             4.11.4                   py35_5  defaults        
                             4.11.4                   py27_6  defaults        
                             4.11.4                   py34_6  defaults        
                             4.11.4                   py35_6  defaults        
                             4.11.4                   py27_7  defaults        
                             4.11.4                   py34_7  defaults        
                             4.11.4                   py35_7  defaults        
                             5.6.0                    py27_0  defaults        
                             5.6.0                    py34_0  defaults        
                             5.6.0                    py35_0  defaults        
                             5.6.0                    py27_1  defaults        
                             5.6.0                    py34_1  defaults        
                             5.6.0                    py35_1  defaults        
                             5.6.0                    py27_2  defaults        
                             5.6.0                    py34_2  defaults        
                             5.6.0                    py35_2  defaults        
                             5.6.0                    py36_2  defaults        
                             5.6.0            py27h224ed30_5  defaults        
                             5.6.0            py35hd46907b_5  defaults        
                             5.6.0            py36hb5ed885_5  defaults  

但它给出了错误:

C:\Users\myuser\Anaconda2\Scripts\conda.exe install pyqt=4.11.4
Fetching package metadata .............
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - navigator-updater -> pyqt >=5.6 -> qt 5.6.*
  - pyqt 4.11.4* -> qt >=4.8.6,<5.0
  - pyqt 4.11.4* -> sip >=4.16.4,<4.18
Use "conda info <package>" to see the dependencies for each package.

-c参数:

C:\Users\myuser\Anaconda2\Scripts\conda.exe install -c anaconda pyqt=4.11.4
Fetching package metadata ...............
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - navigator-updater -> pyqt >=5.6 -> qt 5.6.*
  - pyqt 4.11.4* -> qt >=4.8.6,<5.0
  - pyqt 4.11.4* -> sip >=4.16.4,<4.18
Use "conda info <package>" to see the dependencies for each package.

然后我尝试卸载pyqt

C:\Users\myuser\Anaconda2\Scripts\conda.exe uninstall pyqt

然后重新安装:

C:\Users\myuser\Anaconda2\Scripts\conda.exe install -c anaconda pyqt=4.11.4

终于成功了!

【讨论】:

    【解决方案6】:

    对于 Windows 用户,有一个简单的修复方法。 从以下位置下载 whl 文件:

    https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4

    从 anaconda 提示符运行 pip install PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-17
      • 2016-09-05
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 2018-03-10
      • 2012-10-07
      相关资源
      最近更新 更多