Python 如何在 anaconda 中安装 PyQt4?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21637922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install PyQt4 in anaconda?
提问by user1223862
From the PyQt4 website their instructions for installing the package are to download the tarball and use the config file. I have two versions of Python, one is my normal system and the other is within anaconda. I'm not sure how I get this to install within anaconda. Is there a conda command to install PyQt4?
从 PyQt4 网站,他们安装包的说明是下载 tarball 并使用配置文件。我有两个版本的 Python,一个是我的普通系统,另一个在 anaconda 中。我不确定如何在 anaconda 中安装它。是否有安装 PyQt4 的 conda 命令?
采纳答案by colinfang
FYI
供参考
PyQt is now available on all platforms via conda!
Useconda install pyqtto get these #Python bindings for the Qt framework. @ 1:02 PM - 1 May 2014
PyQt 现在可通过 conda 在所有平台上使用!
用conda install pyqt得到这些#Python绑定Qt框架。@ 1:02 PM - 2014 年 5 月 1 日
回答by user37544
Successfully installed it on OSX using homebrew:
使用自制软件在 OSX 上成功安装它:
brew install sip
brew install pyqt
which (currently) installs PyQt4. Anaconda is the main python on the machine (OSX 10.8.5).
它(当前)安装 PyQt4。Anaconda 是机器上的主要 python (OSX 10.8.5)。
回答by Alaaedeen
It looks like the latest version of anaconda forces install of pyqt5.6 over any pyqt build, which will be fatal for your applications. In a terminal, Try:
看起来最新版本的 anaconda 会强制在任何 pyqt 构建上安装 pyqt5.6,这对您的应用程序来说是致命的。在终端中,尝试:
conda install -c anaconda pyqt=4.11.4
It will prompt to downgrade conda client. After that, it should be good.
它将提示降级 conda 客户端。在那之后,它应该是好的。
UPDATE:If you want to know what pyqt versions are available for install, try:
更新:如果您想知道可以安装哪些 pyqt 版本,请尝试:
conda search pyqt
UPDATE:The most recent version of conda installs anaconda-navigator. This depends on qt5, and should first be removed:
更新:最新版本的 conda 安装了 anaconda-navigator。这取决于qt5,应该首先删除:
conda uninstall anaconda-navigator
Then install "newest" qt4:
然后安装“最新”qt4:
conda install qt=4
回答by Mad Physicist
Updated version of @Alaaedeen's answer. You can specify any part of the version of any package you want to install. This may cause other package versions to change. For example, if you don't care about which specific version of PyQt4 you want, do:
@Alaaedeen's answer 的更新版本。您可以指定要安装的任何软件包的版本的任何部分。这可能会导致其他软件包版本发生变化。例如,如果您不关心您想要哪个特定版本的 PyQt4,请执行以下操作:
conda install pyqt=4
This would install the latest minor version and release of PyQt 4. You can specify any portion of the version that you want, not just the major number. So, for example
这将安装 PyQt 4 的最新次要版本和发行版。您可以指定所需版本的任何部分,而不仅仅是主要版本号。所以,例如
conda install pyqt=4.11
would install the latest (or last) release of version 4.11.
将安装最新(或最后)版本的 4.11。
Keep in mind that installing a different version of a package may cause the other packages that depend on it to be rolled forward or back to where they support the version you want.
请记住,安装不同版本的软件包可能会导致依赖它的其他软件包前滚或回滚到它们支持您想要的版本的位置。
回答by mrgloom
How to install PyQt4 on anaconda python 2 on Windows:
如何在 Windows 上的 anaconda python 2 上安装 PyQt4:
At first I have tried to isntall pyqt4 via pip install:
起初我试图通过pip install以下方式安装 pyqt4 :
C:\Users\myuser\Anaconda2\Scripts\pip.exe search pyqt4 > pyqt4.txt
C:\Users\myuser\Anaconda2\Scripts\pip.exe search pyqt4 > pyqt4.txt
It shows:
表明:
PyQt4 (4.11.4) - Python bindings for the Qt cross platform GUI toolkit
But when I tried to install, it gives an error:
但是当我尝试安装时,它给出了一个错误:
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
Seems this answer is realated to this problem: https://superuser.com/a/725869/213959
似乎这个答案是针对这个问题的:https://superuser.com/a/725869/213959
Then I have tried to install it via conda install( How to install PyQt4 in anaconda?) :
然后我尝试通过conda install(如何在 anaconda 中安装 PyQt4?)来安装它:
C:\Users\myuser\Anaconda2\Scripts\conda.exe search pyqt
It shows:
表明:
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
But it gives error:
但它给出了错误:
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.
Same with -cparameter:
与-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.
Then I tried to uninstall pyqt:
然后我尝试卸载pyqt:
C:\Users\myuser\Anaconda2\Scripts\conda.exe uninstall pyqt
And installed it again:
并再次安装它:
C:\Users\myuser\Anaconda2\Scripts\conda.exe install -c anaconda pyqt=4.11.4
And finnaly it works!
最终它起作用了!
回答by Mister X
Well, here is another way - you could use python to call these commands:
好吧,这是另一种方式 - 您可以使用 python 来调用这些命令:
npm install -g pageres-cli
Then you can simply do this:
然后你可以简单地这样做:
pageres google.com --format=jpg --filename=...
Or if you have wkhtmltoimage installed (sudo apt install wkhtmltopdf), simply do this:
或者,如果您安装了 wkhtmltoimage (sudo apt install wkhtmltopdf),只需执行以下操作:
wkhtmltoimage www....com filename.jpg
So no trouble with any lib or whatever anymore and call these commands from within your python project.
所以没有任何 lib 或其他任何问题,并从您的 python 项目中调用这些命令。
回答by Shankho Ghosh
For windows users, there is an easy fix. Download whl files from:
对于 Windows 用户,有一个简单的修复方法。从以下位置下载 whl 文件:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
run from anaconda prompt pip install PyQt4?4.11.4?cp37?cp37m?win_amd64.whl
从 anaconda 提示符运行 pip install PyQt4?4.11.4?cp37?cp37m?win_amd64.whl

