Can't refrence PyQt5 from pycharm - python

I am using PyCharm 2020.2 and I can't access PyQt5. From the Python interpreter it is showing PyQt5 ver 5.15.0. when I run this simple code
import sys
from PyQt5.QtWidgets import QApplication, QWidget
app = QApplication(sys.argv)
window = QWidget()
window.show()
app.exec_()
I am getting the following error: ModuleNotFoundError: No module named 'PyQt5'
I have no idea where to go next.

Related

PyQt6: DLL load failed while importing QtGui: The specified procedure could not be found

Windows 10 PyCharm Python 3.9.0
I installed PyQt6 and then pyqt6-tools in PyCharm throw the File->Settings.
Now when i run my program i am getting the following error in the terminal
from PyQt6.QtWidgets import QApplication, QWidget
PyQt6: DLL load failed while importing QtGui: The specified procedure could not be found.
My program code
import sys
from PyQt6.QtWidgets import QApplication, QWidget
app = QApplication(sys.args)
window = QWidget()
window.show()
app.exec()
How can i solve this problem?
The following command helped me solve this problem:
pip install --upgrade PyQt6

The exe file generated by PyInstaller does not work when importing colour module

I am working over a project using colour library, using python 3.9 32 bit and pycharm is working, but when I convert it to exe using pyinstaller the exe does not work. To debug I created a simple program, the exe of this program does not work
my system is windows 10 64
converting command
pyinstaller simple_colour.py
import colour
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
class mainwindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.label = QLabel("Colour module is loaded")
self.setCentralWidget(self.label)
app = QApplication([])
window = mainwindow()
window.show()
app.exec_()

module 'PyQt5' has no attribute 'QtWebEngineWidgets'

![My Code][1]
I installed all the libraries using pip and pip3.
I'm using python 3.8.3 and spyder 4.1.4
when ı writing codes IDE show me all libraries in QtWebEngine but trying to start my code IDE says
"module 'PyQt5' has no attribute 'QtWebEngineWidgets'"
and ı have all QtWebEngineWidgets files in computer.
import PyQt5 as py
import sys
app=py.QtWidgets.QApplication(sys.argv)
#app = Py.QApplication(sys.argv)
window = py.QtWidgets.QMainWindow()
window = py.QtWidgets.QWidget()
p=py.QtWebEngineWidgets.QWebEngineView(window)
b=py.QtCore.QUrl('https://stackoverflow.com')
p.load(b)
p.show()
window.setGeometry(0, 35, 400, 400)
window.setWindowTitle("Ground Control")
window.show()
app.exec_()
from PyQt5 import QtWidgets, QtWebEngineWidgets
pop this in and this should get you further

QFileIconProvider (PyQt5) crashes on macOs Catalina

I am trying to create an icon using QFileIconProvider on PyQt5 on macOs Catalina:
from PyQt5.QtWidgets import QFileIconProvider
ip = QFileIconProvider()
ip.icon(QFileIconProvider.Folder)
the former code yields:
zsh: segmentation fault
I am using python 3.7
How can I solve this?
Many of Qt's objects require a QXApplication to be created, and that's the case for QFileIconProvider:
from PyQt5.QtWidgets import QApplication, QFileIconProvider
app = QApplication([])
ip = QFileIconProvider()
icon = ip.icon(QFileIconProvider.Folder)
print(icon, icon.isNull())

PyQt5 stuck on import, but no error message

I installed PyQt5 with conda this way: conda install -c inso pyqt5=5.6. I have python 3.5. When I run a simple program that uses PyQt5, the program gets stuck on PyQt5 import and there is no error message. It gets stuck for about 5 seconds, then the program just terminates. See the example below that I found on google. The program gets stuck on the line from PyQt5.QtWidgets import QApplication, QWidget. I can see the packcage in C:\Users\user\Anaconda3\Lib\site-packages\PyQt5. What might be causing suck a behavior?
"""
ZetCode PyQt5 tutorial
In this example, we create a simple
window in PyQt5.
author: Jan Bodnar
website: zetcode.com
last edited: January 2015
"""
import sys
from PyQt5.QtWidgets import QApplication, QWidget
app = QApplication(sys.argv)
w = QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.show()
sys.exit(app.exec_())
First comment here solved my problem. DLL load failed when importing PyQt5
I uninstalled pyqt5 and reinstalled wtih conda install --channel https://conda.anaconda.org/bpentz pyqt5

Categories

Resources