ModuleNotFoundError: No module named 'qwt_text_label'
ModuleNotFoundError: No module named 'qwt_text_label'
应该很容易解决,但显然不是。我正在尝试 运行 PyQt5 在我的 Ubuntu 18.04 机器上。我已经安装了(或者至少我认为我已经安装了)Qt 和 PyQt5。我什至能够毫无问题地成功执行 pyuic5 main_window.ui -o MainWindow.py
。
但是当我 运行 我的代码出现以下错误时:
Traceback (most recent call last):
File "MainWindow.py", line 79, in <module>
from qwt_text_label import QwtTextLabel
ModuleNotFoundError: No module named 'qwt_text_label'
我缺少什么包裹?我该如何安装它?是链接错误还是路径变量?任何帮助将不胜感激。
安装命令我有运行:
python3.8 -m pip install pyqt5
sudo apt-get install qt5-default
这是我的 main_window.ui:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>970</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTableView" name="tableView">
<property name="geometry">
<rect>
<x>310</x>
<y>20</y>
<width>401</width>
<height>311</height>
</rect>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>350</y>
<width>951</width>
<height>171</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QwtTextLabel" name="recordTimer">
<property name="plainText">
<string>00:00</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="recordButton">
<property name="text">
<string>Record</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="stopButton">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QwtTextLabel" name="TextLabel">
<property name="plainText">
<string>General Instructions</string>
</property>
</widget>
</item>
<item>
<widget class="QwtTextLabel" name="TextLabel_2">
<property name="plainText">
<string>Sentence to be read</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>970</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<customwidgets>
<customwidget>
<class>QwtTextLabel</class>
<extends>QFrame</extends>
<header>qwt_text_label.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
这里是 MainWindow.py:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main_window.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(970, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tableView = QtWidgets.QTableView(self.centralwidget)
self.tableView.setGeometry(QtCore.QRect(310, 20, 401, 311))
self.tableView.setObjectName("tableView")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 350, 951, 171))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.recordTimer = QwtTextLabel(self.verticalLayoutWidget)
self.recordTimer.setObjectName("recordTimer")
self.horizontalLayout_2.addWidget(self.recordTimer)
self.recordButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
self.recordButton.setObjectName("recordButton")
self.horizontalLayout_2.addWidget(self.recordButton)
self.stopButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
self.stopButton.setObjectName("stopButton")
self.horizontalLayout_2.addWidget(self.stopButton)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.line = QtWidgets.QFrame(self.verticalLayoutWidget)
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.verticalLayout.addWidget(self.line)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.TextLabel = QwtTextLabel(self.verticalLayoutWidget)
self.TextLabel.setObjectName("TextLabel")
self.horizontalLayout.addWidget(self.TextLabel)
self.TextLabel_2 = QwtTextLabel(self.verticalLayoutWidget)
self.TextLabel_2.setObjectName("TextLabel_2")
self.horizontalLayout.addWidget(self.TextLabel_2)
self.verticalLayout.addLayout(self.horizontalLayout)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 970, 22))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.recordTimer.setPlainText(_translate("MainWindow", "00:00"))
self.recordButton.setText(_translate("MainWindow", "Record"))
self.stopButton.setText(_translate("MainWindow", "Stop"))
self.TextLabel.setPlainText(_translate("MainWindow", "General Instructions"))
self.TextLabel_2.setPlainText(_translate("MainWindow", "Sentence to be read"))
self.menuFile.setTitle(_translate("MainWindow", "File"))
from qwt_text_label import QwtTextLabel
你试过这样做吗?
from qwt.text import QwtTextLabel
需要 python QWT。
应该很容易解决,但显然不是。我正在尝试 运行 PyQt5 在我的 Ubuntu 18.04 机器上。我已经安装了(或者至少我认为我已经安装了)Qt 和 PyQt5。我什至能够毫无问题地成功执行 pyuic5 main_window.ui -o MainWindow.py
。
但是当我 运行 我的代码出现以下错误时:
Traceback (most recent call last):
File "MainWindow.py", line 79, in <module>
from qwt_text_label import QwtTextLabel
ModuleNotFoundError: No module named 'qwt_text_label'
我缺少什么包裹?我该如何安装它?是链接错误还是路径变量?任何帮助将不胜感激。
安装命令我有运行:
python3.8 -m pip install pyqt5
sudo apt-get install qt5-default
这是我的 main_window.ui:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>970</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTableView" name="tableView">
<property name="geometry">
<rect>
<x>310</x>
<y>20</y>
<width>401</width>
<height>311</height>
</rect>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>350</y>
<width>951</width>
<height>171</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QwtTextLabel" name="recordTimer">
<property name="plainText">
<string>00:00</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="recordButton">
<property name="text">
<string>Record</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="stopButton">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QwtTextLabel" name="TextLabel">
<property name="plainText">
<string>General Instructions</string>
</property>
</widget>
</item>
<item>
<widget class="QwtTextLabel" name="TextLabel_2">
<property name="plainText">
<string>Sentence to be read</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>970</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<customwidgets>
<customwidget>
<class>QwtTextLabel</class>
<extends>QFrame</extends>
<header>qwt_text_label.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
这里是 MainWindow.py:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main_window.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(970, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tableView = QtWidgets.QTableView(self.centralwidget)
self.tableView.setGeometry(QtCore.QRect(310, 20, 401, 311))
self.tableView.setObjectName("tableView")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 350, 951, 171))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.recordTimer = QwtTextLabel(self.verticalLayoutWidget)
self.recordTimer.setObjectName("recordTimer")
self.horizontalLayout_2.addWidget(self.recordTimer)
self.recordButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
self.recordButton.setObjectName("recordButton")
self.horizontalLayout_2.addWidget(self.recordButton)
self.stopButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
self.stopButton.setObjectName("stopButton")
self.horizontalLayout_2.addWidget(self.stopButton)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.line = QtWidgets.QFrame(self.verticalLayoutWidget)
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.verticalLayout.addWidget(self.line)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.TextLabel = QwtTextLabel(self.verticalLayoutWidget)
self.TextLabel.setObjectName("TextLabel")
self.horizontalLayout.addWidget(self.TextLabel)
self.TextLabel_2 = QwtTextLabel(self.verticalLayoutWidget)
self.TextLabel_2.setObjectName("TextLabel_2")
self.horizontalLayout.addWidget(self.TextLabel_2)
self.verticalLayout.addLayout(self.horizontalLayout)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 970, 22))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.recordTimer.setPlainText(_translate("MainWindow", "00:00"))
self.recordButton.setText(_translate("MainWindow", "Record"))
self.stopButton.setText(_translate("MainWindow", "Stop"))
self.TextLabel.setPlainText(_translate("MainWindow", "General Instructions"))
self.TextLabel_2.setPlainText(_translate("MainWindow", "Sentence to be read"))
self.menuFile.setTitle(_translate("MainWindow", "File"))
from qwt_text_label import QwtTextLabel
你试过这样做吗?
from qwt.text import QwtTextLabel
需要 python QWT。