开发环境路径1
参考:https://blog.csdn.net/richenyunqi/article/details/80302884
1.1
python.org/downloads/release/python-362/ 下载Windows x86-64 executable installer 也就是 python-3.6.2-amd64.exe
1.2
pip install pyqt5
1.3测试 写1.py
import sys
from PyQt5.QtWidgets import QWidget, QApplication
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.show()
w.setWindowTitle("Hello PyQt5")
sys.exit(app.exec_())
可以看到效果了。
开发环境路径2
参考:https://mp.weixin.qq.com/s/0PBLpyf-NyQq8RRQ0_B-pw
1.2准备:
anaconda.exe:https://www.anaconda.com/download/
PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x32-2.exe:https://sourceforge.net/projects/pyqt/files/PyQt5/
eric6.exe:http://eric-ide.python-projects.org/eric-download.html
1.2安装anaconda 最后会顺便安装VS code
1.3
1.4
C:\Users\Gong Jin Hua\AppData\Local\Programs\Python\Python36\Scripts 找到.CMD
之后你就可以在eric6上编写python程序了
++++++++++++上面的宣告失败ERIC6实在不会++++++++++++++
第三种方案:https://blog.csdn.net/m0_37251750/article/details/81269385
验证: 安装3.5的
python
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
CMD安装:1
pip install pyqt5
安装:2
pip install PyQt5-tools
此时可自己跑上面的程序 方案1的
继续安装pycharm 社区版本 不要钱
设置:
C:\Users\Gong Jin Hua\AppData\Local\Programs\Python\Python35\Lib\site-packages\pyqt5_tools\designer.exe
C:\Users\Gong Jin Hua\AppData\Local\Programs\Python\Python35\python.exe
可以了 但是可以在桌面跑 在IDE跑有问题!
File "C:/Users/Gong Jin Hua/PycharmProjects/1/u.py", line 9, in <module>
from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: No module named 'PyQt5'
怎么办?
https://blog.csdn.net/leemboy/article/details/80490675
修改为true就可以的 是环境不对头!
需要 的代码:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(150, 140, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Form)
self.pushButton.clicked.connect(Form.close)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "PushButton"))
if __name__=="__main__":
import sys
app=QtWidgets.QApplication(sys.argv)
widget=QtWidgets.QWidget()
ui=Ui_Form()
ui.setupUi(widget)
widget.show()
sys.exit(app.exec_())
if __name__=="__main__":
app = QtWidgets.QApplication(sys.argv)
tem = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(tem)
tem.show()
sys.exit(app.exec_())