简体   繁体   English

如何在anaconda中安装PyQt4?

[英]How to install PyQt4 in anaconda?

From the PyQt4 website their instructions for installing the package are to download the tarball and use the config file. 从PyQt4网站上,他们安装软件包的说明是下载tarball并使用配置文件。 I have two versions of Python, one is my normal system and the other is within anaconda. 我有两个版本的Python,一个是我的普通系统,另一个是anaconda。 I'm not sure how I get this to install within anaconda. 我不知道如何安装在anaconda中。 Is there a conda command to install PyQt4? 是否有conda命令来安装PyQt4?

Updated version of @Alaaedeen's answer . @Alaaedeen答案的更新版本。 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: 例如,如果您不关心所需的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. 这将安装PyQt 4的最新次要版本和版本。您可以指定所需版本的任何部分,而不仅仅是主要编号。 So, for example 所以,例如

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. 请记住,安装不同版本的软件包可能会导致依赖它的其他软件包前滚或返回到它们支持所需版本的位置。

FYI FYI

PyQt is now available on all platforms via conda! PyQt现在可通过conda在所有平台上使用!
Use conda install pyqt to get these #Python bindings for the Qt framework. 使用conda install pyqt为Qt框架获取这些#Python绑定。 @ 1:02 PM - 1 May 2014 @ 1:02 PM - 2014年5月1日

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

It looks like the latest version of anaconda forces install of pyqt5.6 over any pyqt build, which will be fatal for your applications. 看起来最新版本的anaconda强制安装pyqt5.6比任何pyqt构建,这对你的应用程序来说是致命的。 In a terminal, Try: 在终端中,尝试:

conda install -c anaconda pyqt=4.11.4

It will prompt to downgrade conda client. 它会提示降级conda客户端。 After that, it should be good. 在那之后,它应该是好的。

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. 更新:最新版本的conda安装anaconda-navigator。 This depends on qt5, and should first be removed: 这取决于qt5,应首先删除:

conda uninstall anaconda-navigator

Then install "newest" qt4: 然后安装“最新”qt4:

conda install qt=4

Successfully installed it on OSX using homebrew: 使用自制程序在OSX上成功安装它:

brew install sip
brew install pyqt     

which (currently) installs PyQt4. (当前)安装PyQt4。 Anaconda is the main python on the machine (OSX 10.8.5). Anaconda是机器上的主要python(OSX 10.8.5)。

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 isntall pyqt4:

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 -c parameter: -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! 并且finnaly它的作品!

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项目中调用这些命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM