PyQt4 在 Ubuntu 上安装问题 [英] PyQt4 install problems on Ubuntu

查看:49
本文介绍了PyQt4 在 Ubuntu 上安装问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 上安装了 PyQt4 并使用 Python2.7 运行,这很好用.现在我想在 Python3 中使用 PyQt4.

I have PyQt4 installed and running with Python2.7 on Ubuntu, this works fine. Now I want to use PyQt4 with Python3.

  • 我已经尝试了几个小时来使用 Python3.4 安装 PyQt4.
  • 我安装了 sip-4.16.4.这工作得很好.
  • 然后我尝试安装 PyQt-x11-gpl-4.11.3.

我收到一条消息:

Qt Designer 插件被禁用,因为找不到动态 Python 库.

The Qt Designer plugin was disabled because a dynamic Python library could not be found.

然后我运行 make 并遇到一个错误,无法找到 Python.h.然后我根据 this answer

I then ran make and had an error that Python.h could not be found. I then created a sym link as per this answer

然后我再次运行 make 我得到一个错误:

I then ran make again I got an error:

致命错误abstractaudiooutput.h 没有这样的文件或目录,编译被终止.

fatal error abstractaudiooutput.h No such file or directory and compilation was terminated.

我尝试了一个虚拟环境并从头安装了pyhton3.4.事情比以前进步了很多,但是我再次遇到了 abstractaudiooutput.h 的错误.

I tried a virtual environment and installed pyhton3.4 from scratch. Things progressed much further than previously but then I again got the same error with abstractaudiooutput.h.

推荐答案

让 pyQt4 在 Ubuntu 中工作的一种方法:安装 Ubuntu14.04安装 virtualenv 和 virtualenvwrapper 例如 virtualenvvirtualenvwrapper

One way to get pyQt4 working in Ubuntu: Install Ubuntu14.04 Install virtualenv and virtualenvwrapper eg virtualenv, virtualenvwrapper

创建一个python3 virtualenv

Create a python3 virtualenv

mkvirtualenv testpy3 -p /usr/bin/python3.4

现在您应该在命令行的开头看到 (testpy3).在这个 shell 中安装 sip(我以这种方式工作,但根据下面的 pyQt 从 Riverbankcomputing 下载最新版本可能更好)

Now you should see (testpy3) at start of command line. In this shell install sip (I got it working this way but may be better to download latest from riverbankcomputing as per pyQt below)

pip install sip
make
sudo make install

http://www.riverbankcomputing.com/software/pyqt/downloadcd 到下载文件夹,解压下载的文件.cd 进入解压后的文件夹.输入

download pyQt from http://www.riverbankcomputing.com/software/pyqt/download cd to the download folder, unpack the downloaded file. cd into the unpacked folder. type

python configure-ng.py
make
sudo make install

现在测试

python
>>import PyQt4

这应该没有错误.现在在 PyCharm文件->设置->项目:项目解释器选择顶部的齿轮图标RHS->添加本地导航到您的testpy3 virtualenv(例如在/home/user/.virtualenvs).通过 PyQt4 没有出现在包列表中,PyCharm 检测到它并且 PyQt4 gui 正在为我工​​作.

This should work without errors. Now in PyCharm file->settings->Project:Project Interpreter select the gear icon on topRHS->add local navigate to your testpy3 virtualenv (eg in /home/user/.virtualenvs). Through PyQt4 doesn't appear in the package list, PyCharm detected it and PyQt4 gui's are working for me.

这篇关于PyQt4 在 Ubuntu 上安装问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆