No module named pyqt4 linux

No module named ‘PyQt4.sip’

I’ve tried to reproduce your error and in fact I succeeded in doing that. I have a Debian system, so I used apt to install all the packages I wanted to install.

I tried to run in an interactive python environment (sorry for the bad terminology, I’m not proficient in python: I used it only a few times to solve very simple math problems) the code

The first try to solve the problem was installing the packages pyqt4-dev-tools and pyqt4.qsci-dev , which did not solve the problem. So I tried to install the package python-qt4 , which happened to be already installed in my system. Then I tried to install python-qtpy , which did not work either. Then I stumbled upon this question on StackOverflow, which gave me the idea that I was using the wrong python version (by default I use python 3.7), so I tried to run the aforementioned command in a python 2.7 and it worked.

Now, because I was disappointed by the lack of support of python 3, I tried to look for some other packages about qt and python 3 and I found python3-qtpy . I installed it and the command. still did not work. However, while it was installing, I noticed that it was installing the version 3 of the qt libraries, so I tried to run, in the interactive python 3 environment, from PyQt5.QtGui import * and it worked.

Some notes: I saw that it also installed python3-sip together with python3-qtpy and that I’ve already installed on my system the package python-sip ; not sure if this helps. Another note I want to make is that I use Debian, but you did not specify your distribution. This wouldn’t in general be a problem as python should not be dependent on the OS it’s running on, however, having used apt and the Debian repos to install all the required dependencies might be an influencing variable in the solution of the problem. As I mentioned before, I rarely use python, but I know you can use pip to install new «packages» or the StackOverflow answer uses brew. The only thing to check is the python version you install your packages for. EDIT: If you need it, have a look at python qtpy version 4 on pip and python qtpy version 5 on pip

Читайте также:  Сеть есть интернета нет linux

Now, I tried to be as detailed as possible in explaining what I did to solve the import problem, but if you have some more question, feel free to add a comment below.

Источник

PyQt4, Centos7 and Python3- ImportError: No module named ‘PyQt4’

I’m working on Centos7 and using Python 3.3.2. I’m trying to run a Python script that uses PyQt4 modules but I’m getting this error:

ImportError: No module named 'PyQt4' 

The script doesn’t yet have it’s full functionality but I’m just trying to ensure it runs and can access the correct modules etc at this early stage as I’m new to python. Here is the script so far:

#!/usr/bin/env python3 from PyQt4 import QtCore, QtGui from os.path import expanduser import os import shlex #import Converted Python UI File from mainwindow import Ui_MainWindow class Main(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) # Connect the Buttons QtCore.QObject.connect(self.ui.selectFileButton,QtCore.SIGNAL("clicked()"),self.selectFile) QtCore.QObject.connect(self.ui.convertButton,QtCore.SIGNAL("clicked()"),self.convert) def selectFile(self): fileName = QtGui.QFileDialog.getOpenFileName(self,'Open Media File',expanduser("~"),'Media Files (*.mov *.avi *.mkv *.mpg)') self.ui.fileName.setText(fileName) def convert(self): self.convertFile() def main(): app = QtGui.QApplication(sys.argv) window = Main() window.show() sys.exit(app.exec_()) #if __name__ == “__main__”: main() 
/usr/lib64/python2.7/site-packages/PyQt4 /usr/lib64/python2.7/site-packages/PyQt4/Qt.so /usr/lib64/python2.7/site-packages/PyQt4/QtCore.so /usr/lib64/python2.7/site-packages/PyQt4/QtDBus.so /usr/lib64/python2.7/site-packages/PyQt4/QtDeclarative.so /usr/lib64/python2.7/site-packages/PyQt4/QtDesigner.so /usr/lib64/python2.7/site-packages/PyQt4/QtGui.so /usr/lib64/python2.7/site-packages/PyQt4/QtHelp.so /usr/lib64/python2.7/site-packages/PyQt4/QtMultimedia.so /usr/lib64/python2.7/site-packages/PyQt4/QtNetwork.so /usr/lib64/python2.7/site-packages/PyQt4/QtOpenGL.so /usr/lib64/python2.7/site-packages/PyQt4/QtScript.so /usr/lib64/python2.7/site-packages/PyQt4/QtScriptTools.so /usr/lib64/python2.7/site-packages/PyQt4/QtSql.so /usr/lib64/python2.7/site-packages/PyQt4/QtSvg.so /usr/lib64/python2.7/site-packages/PyQt4/QtTest.so /usr/lib64/python2.7/site-packages/PyQt4/QtXml.so /usr/lib64/python2.7/site-packages/PyQt4/QtXmlPatterns.so /usr/lib64/python2.7/site-packages/PyQt4/__init__.py /usr/lib64/python2.7/site-packages/PyQt4/__init__.pyc /usr/lib64/python2.7/site-packages/PyQt4/__init__.pyo /usr/lib64/python2.7/site-packages/PyQt4/phonon.so /usr/lib64/python2.7/site-packages/PyQt4/pyqtconfig.py /usr/lib64/python2.7/site-packages/PyQt4/pyqtconfig.pyc /usr/lib64/python2.7/site-packages/PyQt4/pyqtconfig.pyo /usr/lib64/python2.7/site-packages/PyQt4/uic /usr/lib64/python2.7/site-packages/PyQt4/uic/Compiler 

Which suggests PyQt is installed to work with Python2. How can I correct this so that it works with Python 3.3.2? I’ve tried yum install python-pyqt4 but on Centos there doesn’t seem to be a package available. Any ideas? Thanks

Источник

Python 3.8 pytest-qt ModuleNotFoundError: No module named ‘PyQt4’

I have created my project on Linux mint 19 with python 3.6 installed. I used pytest in conjunction with pytest-qt to test my app which is a PyQt5 program. Then, I’ve updated to Linux mint 20. However python 3.8 is installed there instead of 3.6. I don’t know whether it’s related or not but now I can’t run my test suite anymore, when I type pytest in terminal it gives me the following output:

Traceback (most recent call last): File "/home/kotlin/.local/bin/pytest", line 8, in sys.exit(console_main()) File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 187, in console_main code = main() File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 143, in main config = _prepareconfig(args, plugins) File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 318, in _prepareconfig config = pluginmanager.hook.pytest_cmdline_parse( File "/home/kotlin/.local/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__ return self._hookexec(self, self.get_hookimpls(), kwargs) File "/home/kotlin/.local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "/home/kotlin/.local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( File "/home/kotlin/.local/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall gen.send(outcome) File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse config = outcome.get_result() # type: Config File "/home/kotlin/.local/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "/home/kotlin/.local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall res = hook_impl.function(*args) File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1003, in pytest_cmdline_parse self.parse(args) File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1280, in parse self._preparse(args, addopts=addopts) File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1172, in _preparse self.pluginmanager.load_setuptools_entrypoints("pytest11") File "/home/kotlin/.local/lib/python3.8/site-packages/pluggy/manager.py", line 299, in load_setuptools_entrypoints plugin = ep.load() File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load module = import_module(match.group('module')) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 171, in exec_module exec(co, module.__dict__) File "/home/kotlin/.local/lib/python3.8/site-packages/pytestqt/plugin.py", line 7, in from pytestqt.qt_compat import QtCore, QtGui, QtTest File "/home/kotlin/.local/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 171, in exec_module exec(co, module.__dict__) File "/home/kotlin/.local/lib/python3.8/site-packages/pytestqt/qt_compat.py", line 31, in import PyQt4.QtCore as _QtCore ModuleNotFoundError: No module named 'PyQt4' 

At the end it says ModuleNotFoundError: No module named ‘PyQt4’ but I don’t even use PyQt4, I use PyQt5 instead. I have pytest and pytest-qt both installed. The program itself works properly. Thanks.

Читайте также:  Package installer on linux

Источник

Оцените статью
Adblock
detector