简体   繁体   English

无法导入 PyQt5.QtWebEngineWidgets

[英]Can't import PyQt5.QtWebEngineWidgets


I'm trying to make an vocabtrainer for myself to get better in english, cause I suck.我正在尝试为自己制作一个词汇训练师,以提高英语水平,因为我很烂。 To achieve this, I'm trying to make a GUI with PyQt5 to expand my programming experience too :).为了实现这一点,我正在尝试使用 PyQt5 制作一个 GUI 来扩展我的编程经验:)。 But somehow I can't import the QtWebEngineWidget ...但不知何故我无法导入QtWebEngineWidget ...

This is my code:这是我的代码:

import PyQt5.QtWidgets as pyqtW
import PyQt5.QtGui as pyqtG
import PyQt5.QtCore as pyqtC
from PyQt5.QtWebEngineWidgets import *

import sys


class VocabTrainer:

    def __init__(self):
        self.main = pyqtW.QApplication([])
        self.window = pyqtW.QWidget()

        self.prepareWindow()

        sys.exit(self.main.exec_())

    def prepareWindow(self):
        """
        Set's the attributes of the window.
        """

        # window settings
        self.window.resize(250, 100)
        self.window.show()

    def openPons(self):
        """
        Opens the website of pons to be able to translate words.
        """
        pass

test = VocabTrainer()

My IDE (PyCharm) warns me that it can't find the reference of PyQt5.QtWebEngineWidgets and if I run this code, I'll get this error message:我的 IDE (PyCharm) 警告我它找不到PyQt5.QtWebEngineWidgets的引用,如果我运行此代码,我将收到此错误消息:

Traceback (most recent call last):
  File "/A/little/path/VocabTrainer.py", line 12, in <module>
    from PyQt5.QtWebEngineWidgets import *
ImportError: libQt5Quick.so.5: cannot open shared object file: No such file or directory

Process finished with exit code 1

I've installed the modules with the following commands:我已经使用以下命令安装了模块:

pip install pyqt5
pip install pyqtwebengine

I've also tried to reinstall the modules but without success.我也尝试重新安装模块,但没有成功。

Python-Version: 3.8.1 Python 版本:3.8.1
OS: Arch Linux操作系统:Arch Linux

In the case of ArchLinux, having the most up-to-date packages, I generally recommend using the repository packages (IMHO Arch Linux is a good laboratory to test the new functionalities :-)).在 ArchLinux 的情况下,拥有最新的软件包,我通常建议使用存储库软件包(恕我直言,Arch Linux 是测试新功能的好实验室:-))。 Considering the above, I recommend installing pyq5 and pyqtwebengine by running the following:考虑到上述情况,我建议通过运行以下命令来安装 pyq5 和 pyqtwebengine:

sudo pacman -S python-pyqt5 python-pyqtwebengine

You must also change the python that pycharm uses to the system.您还必须将pycharm 使用的python 更改为系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM