本文介绍了我如何添加或导入 pyqt 和 sip 到 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在导入这个时遇到问题.我是新手,所以请使用我可以遵循的外行话:p.河岸说我需要喝一口.但是我安装的 pyqt 下载中有一个 sip 文件夹,所以我已经有了它吗?这个网站上有一些相关的问题,导致我尝试这些方法:..我的pyqt文件夹是PyQt-win-gpl-4.9.4.所以我输入:sys.path.append('C:\Program Files\PyQt-win-gpl-4.9.4\sip') 这很好,在'sip'文件夹内,它有一堆文件夹,如QtCore等......和我试过这样导入:

im having trouble importing this. i am a newbie so please use layman words i can follow:p. riverbank said i need sip. but there is a sip folder in the pyqt download i installed, so do i have it already? there are some related questions on this site, which lead me to try these method:.. my pyqt folder is PyQt-win-gpl-4.9.4. so i typed:sys.path.append('C:\Program Files\PyQt-win-gpl-4.9.4\sip') this adds it fine, inside the 'sip' folder, it has a bunch of folders like QtCore etc.. and ive tried importing like this:

from sip import QtCore

导入错误:没有名为 sip 的模块

ImportError: No module named sip

import sip

导入错误:没有名为 sip 的模块

ImportError: No module named sip

谁能告诉我我做错了什么?我应该在原始 Python 文件夹中安装 PyQt 吗?我真的希望能够在尝试学习它的同时输入代码,因为它变得非常混乱.谢谢

Can someone please tell me what im doing wrong? should i have just installed PyQt in the original Python folder? i really want to be able to type the code while trying to learn it as its getting very confusing. thanks

推荐答案

文件夹名称 PyQt-win-gpl-4.9.4 属于 source 包.

The folder name PyQt-win-gpl-4.9.4 belongs to the source package.

对于 Windows,您需要的是 binary 包.二进制包包含 PyQt 开发所需的一切(包括 Qt 本身).唯一的要求是您首先安装了 Python.

For Windows, what you need is the binary package. The binary package contains everything you need for PyQt development (including Qt itself). The only requirement is that you have Python installed first.

返回河岸下载页面,向下滚动一点,然后您将找到各种 Python 版本的安装程序列表.下载适合您系统的那个,然后运行它.

Go back to the riverbank download page, scroll down a bit, and you will find a list of installers for various versions of Python. Download the one that is appropriate for your system, and run it.

完成后,启动 Python 解释器并执行以下操作:

Once you've done that, fire up a Python interpreter and do:

from PyQt4 import QtCore, QtGui

确保一切正常.

如果您需要教程,PyQt Wiki 是一个不错的起点.

If you need tutorials, the PyQt Wiki is not a bad place to start.

这篇关于我如何添加或导入 pyqt 和 sip 到 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 16:46