How do i add or import pyqt and sip to Python

十年热恋 提交于 2021-02-07 20:29:47

问题


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

ImportError: No module named sip

or

import sip

ImportError: No module named sip

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


回答1:


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

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.

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.

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

from PyQt4 import QtCore, QtGui

to make sure everything is working correctly.

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




回答2:


Copying sip.pyd from folder PyQt5_sip-4.19.12-py3.7-win-amd64.egg to PyQt5-5.11.2-py3.7-win-amd64.egg did the trick for me.....It does not seem to be right approach but at least you will not stuck in waiting for fixes to come...Please let me know if still do not work....



来源:https://stackoverflow.com/questions/12285782/how-do-i-add-or-import-pyqt-and-sip-to-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!