I am new to python and I have an issue running PyQT5 for my Python 3.3 on PyCharm.
I have read several posts about it, some speaking about doing a build which I am not sure to get.
Here is what I have done :
Downloaded and run the .exe found here.
Installing normally, the same way as my Pillow for instance (which is running with my Pycharm).
aaaand, that's its.
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
== from PyQt5.QtCore import *
ImportError: No module named 'PyQt5.QtCore'
When I setup the module in PyCharm it simply didn't find it. So is the .exe found on the official PyQT5 dead ?
Thanks
Bloby
I also met the same problem recently, maybe you also install PyQt5 by pip?
It seems that the after using pip, I can import the PyQt5 but not any packages of it, so I have to download the old version with an installer.
Then Pycharm can runs without error.
Related
I have been using the QT designer tool which saves GUIs as a XML template. PySide2 is able to covert this to a Python Class file.
Utilizing the tool for an XML that includes QWebEngineView
pyside2-uic GUI_NEW.ui > ui_main.py
The first few lines of the ui_main.py call for
################################################################################
## Created by: Qt User Interface Compiler version 5.15.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from QWebEngineView import QWebEngineView
running the file that utilizes this, results in:
ModuleNotFoundError: No module named 'QWebEngineView'
So far I have tried
Trying PySide6 over PySide 2
Replaced the import line with
from PySide2.QtWebEngineWidgets import QWebEngineView
The Application runs but completely hangs
pip install PyQtWebEngine
pip install PyQt5==5.11.3
Cleaning up, installing all references to Qt (Pyside, PyQT, etc), and re-installing
Attempted all the above on python 3.6 - 3.8
Here is another option, you don't have it.
Then try this option:
from PyQt5 import QtWebEngineWidgets
That is, an example of a string:
self.webView = QtWebEngineWidgets.QWebEngineView(self.centralwidget)
But, unfortunately Qt, PyQt and PySide should never be used together. Most problems occur when trying to re-display a widget created with a binding with another one created with a different binding.
The solution is simple: you either use PyQt5 and use QtWebEngineWidgets, or PySide2.
As a last resort, try installing a newer version (5.12)(PyQt5) and install PyQtWebEngine separately.
Ultimately I stuck to PySide2 (option 2), creating a new project specific python environment that did not involve PyQt5. This prevented the application from hanging with zero console errors.
I would like to use PyQt5 on my PyCharm but If I try to import it I get
ImportError: No module named PyQt5.
I looked for hours other answers but the issue doesn't seem to be fixed. I'm running MacOS X 10.13, PyCharm 2019.3. What puzzles me is that if on PyCharm I go to
Preferences > Project interpreter
then PyQt5 shows up among the packages that I have installed. Could anybody help?
I am new to the world of python and I was hoping you could help with my PyQt5 installation troubles.
I have downloaded PyQt5 (zip folder) for Windows and extracted onto my desktop.
Source: https://www.riverbankcomputing.com/software/pyqt/download5
As instructed in the read me file, I have also installed the latest SIP package (also extracted to the desktop) and I have run the configure.py in python 3.5 to receive the following error:
Error: Use the --qmake argument to explicitly specify a working Qt qmake.
Does anyone know why this may be? Or how I fix it and complete the install?
Additionally, I have watched a tutorial on YouTube... https://www.youtube.com/watch?v=JBME1ZyHiP8
However when trying to run his code (shown below) I get the:
'ImportError: No module named 'PyQt5'
Is this linked to the install issues?
Code:
import sys
from PyQt5 import QtGui
app = QtGui.QApplication (sys.argv)
window = QtGui.Qwidget()
window.setGeometry (50, 50, 800, 500)
window.setWindowTitle("GIS Demonstration")
window.show()
Am I missing something? All solutions welcome.
Thanks,
Jodie
I install it with the cmd (shell):
pip install pyqt5
this works for my
I am using Anaconda with Python 3.5.2, Matplotlib 2.0.2, PyQt5.6 on a windows 10 machine. When I import matplotlib.pyplot as plt I get the following error:
...
File "C:...\Anaconda3\Lib\site-packages\matplotlib\backends\qt_compat.py",
line 137, in <module> from PyQt4 import QtCore, QtGui
ImportError: No module named 'PyQt4'
I don't know why it would want to import from PyQt4 when it has never been installed on my machine.
This question has the same error, but on a machine that actually has PyQt4 installed.
I have checked my matplotlibrc file, I've used matplotlib.use('qt5agg') in the program, also matplotlib.rcParams['backend'] = "Qt5Agg". I've uninstalled and reinstalled all the above packages to no avail. I have even attempted to install PyQt4 just to get things going. I'm completely stumped. None of the various possible causes or remedies that I've been able to find on either SO or github have helped.
I just had the same error (even though on Windows 7). For me the problem was that there was an old matplotlibrc file in C:\Users\<username>\.matplotlib\matplotlibrc which overwrote the settings from my environment's matplotlibrc file. Deleting that file solved the issue for me.
It seems the API version is PyQt5 but the default is PyQt4,just open Tools -> Preferences -> IPython console -> Graphics -> backend,change QT4 to QT5
Looking at the file and line number in your error it looks that you have the same issue that I answered here.
That is, I think your issue is caused by having a QT_API environment variable that still is set to pyqt4 (or pyside).
I ran into a similar thing and found that the problem was having a 64-bit Anaconda installation that couldn't load the PyPt5 DLLs that were perhaps 32-bit. The short answer is that I uninstalled Anaconda 64-bit and installed the 32-bit version instead.
To work through this, I stepped through qt_compat.py where the error originates. For most of the time through this module, it’s trying to work with PyQt5, as that’s what it finds in the environment. However, when it gets to the lines below, the import fails so it tries to fall back to PyQt4, which isn’t installed with Anaconda, and thus issues the error.
if QT_API == QT_API_PYQT5:
try:
from PyQt5 import QtCore, QtGui, QtWidgets
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
except ImportError:
# fell through, tried PyQt5, failed fall back to PyQt4
QT_API = rcParams['backend.qt4']
QT_RC_MAJOR_VERSION = 4
Testing the import statement outside of the file gave the message “DLL load failed: %1 is not a valid Win32 application.” That's what suggests the DLL mismatch, and also answers why it was trying to fall back to PyQt4.
3 steps can solve this problem:
pip uninstall pyqt5
pip uninstall matplotlib
pip install matplotlib
I had faced the same problem and here is how I fixed it.
Look into your matplotlib configuration file which is often located at
path-to/site-packages/matplotlib/mpl-data/matplotlibrc
or
path-to/Anaconda3/envs/your_env_name/Lib/site-packages/matplotlib/mpl-data/matplotlibrc
See an example of matplotlibrc here
https://github.com/daler/matplotlibrc/blob/master/rc/default
If you have pyqt5.x.x installed and have the statement 'backend : Qt5Agg' in matplotlibrc, then to use '%matplotlib qt', change '#backend.qt4 : PyQt4' to '#backend.qt4 : PyQt5'.
For an Anaconda environment, reactivate the environment.
Note if you update matplotlib in the future, your matplotlibrc will automatically be overwritten.
I want to use qt with python.
"import qt" return me :"ImportError: No module named qt". I already instaled pyqt.
what I hve to install in order to activate "import qt"
Thank You
The current PyQt comes in the PyQt4 package, which has several modules. You almost always need to start with:
from PyQt4 import QtCore
from PyQt4 import QtGui
Add other imports as necessary if you need additional sub-modules of PyQt (like QtNetwork, QtSql etc).
Tip for the future: find the lib/site-packages library of your Python installation and look at the packages in there if you're not sure about the name after installing.
Also, arm yourself with a PyQt tutorial - any decent one covers this in the first few paragraphs.
import PyQt4 works for me fine.