您尚未登录。

楼主 #1 2020-02-19 11:11:27

pythinker
会员
注册时间: 2019-02-12
已发帖子: 215
积分: 215

python3.7 使用 pip 命令安装 PySide2 Qt5 软件包了, 也可以手动安装.

E:>E:\Python37\python.exe -m pip install PySide2
Collecting PySide2
  Using cached https://files.pythonhosted.org/packages/a0/d3/5e8811ddc6c0e794c26
c87eb9c32e66930a46d6b19e61cbce79e5c5f6865/PySide2-5.14.1-5.14.1-cp35.cp36.cp37.c
p38-none-win_amd64.whl
Requirement already satisfied: shiboken2==5.14.1 in E:\python37\lib\site-
packages (from PySide2) (5.14.1)
Installing collected packages: PySide2
Successfully installed PySide2-5.14.1

也可以手动下载安装: PySide2-5.14.1-5.14.1-cp35.cp36.cp37.cp38-none-win_amd64.whl

离线

楼主 #2 2020-02-19 11:14:09

pythinker
会员
注册时间: 2019-02-12
已发帖子: 215
积分: 215

Re: python3.7 使用 pip 命令安装 PySide2 Qt5 软件包了, 也可以手动安装.

# This Python file uses the following encoding: utf-8
import sys,os
import PySide2
from PySide2.QtWidgets import QApplication, QMainWindow


class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)


if __name__ == "__main__":
    app = QApplication([])
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())

不知道是不是由于安装了 PyQt5 冲突的缘故, 报如下错误:

qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

离线

楼主 #3 2020-02-19 11:18:36

pythinker
会员
注册时间: 2019-02-12
已发帖子: 215
积分: 215

Re: python3.7 使用 pip 命令安装 PySide2 Qt5 软件包了, 也可以手动安装.

找到解决方案了: https://blog.csdn.net/ouening/article/details/81093697

# This Python file uses the following encoding: utf-8
import sys,os
import PySide2

dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

from PySide2.QtWidgets import QApplication, QMainWindow


class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)


if __name__ == "__main__":
    app = QApplication([])
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())

2020-02-19_111801.gif

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn