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
Related
I'm trying to create a mini web browser, but I'm having some problems with PyQtWebEngine. When I run the code the window appear but It's blank, that window don't show me the page (In this case of test I'm trying to connect with Google).
I've already tried to reinstall PyQt5, PyQtWebEngine and I've already create a Virtual Enviroment with venv (as I see here) but seems that nothing could fix it.
I run the code with debug mode with F5 and run using QT_DEBUG_PLUGINS=1 but they show me no errors.
This is the code (I'm just following this example)
import sys
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
web = QWebEngineView()
web.load(QUrl('https://google.it/'))
web.show()
sys.exit(app.exec_())
And this is the window when I run the code
I'm editing this code with Microsoft Visual Code, running on Ubuntu 22.04.1.
I got the same problem with your code on Linux Mint 21 (based on Ubuntu 22.04).
Even other examples from tutorials had the same problem.
this answer helped me to resolve this problem. I describe it with more details.
I got all installed modules for PyQt5
pip3 freeze | grep -i pyqt
PyQt5==5.15.7
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.0
PyQtWebEngine==5.15.6
PyQtWebEngine-Qt5==5.15.2
and I unistalled all of them
pip3 uninstall PyQt5 PyQt5-Qt5 PyQt5-sip PyQtWebEngine PyQtWebEngine-Qt5
And later I installed QtWebEngine using apt
(apt automatically installed also PyQt5 and I didn't need to use pip for this)
apt install python3-pyqt5.qtwebengine
It installed also other C/C++ libraries - and maybe this was needed to work corrrectly.
The following additional packages will be installed:
libqt5designer5 libqt5qml5 libqt5qmlmodels5 libqt5quick5 libqt5quickwidgets5 libqt5test5 libqt5webchannel5
libqt5webengine-data libqt5webengine5 libqt5webenginecore5 libqt5webenginewidgets5 libre2-9 python3-pyqt5
python3-pyqt5.qtwebchannel python3-pyqt5.sip
And now pip3 freeze shows me:
PyQt5==5.15.6
PyQt5-sip==12.9.1
PyQtWebEngine==5.15.5
And now your code works for me.
Similar questions:
python - Unable to render webpage using QWebEngineView - Stack Overflow
python 3.x - PyQt5 QWebEngineView does not show webpage - Stack Overflow
python - Displaying web page with PyQt5 WebEngine - Stack Overflow
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 have several different qt packages installed for my development environment on Ubuntu 15.04 (3.19.0-51-generic), and I can't seem to get my imports correct. The error I am running into in PyCharm is:
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ImportError: No module named 'PyQt5.QtWebEngineWidgets'
The following packages I have installed already, which I believe to be relevant are as follows:
python3-pyqt5
python3-pyqt5-dbg
python-pyqt5
python-pyqt5-dbg
pyqt5-dev-tools
pyqt5-dev
python-pyqt5.qtwebkit
python3-pyqt5.qtwebkit
python-pyqt5.qtwebkit-dbg
python3-pyqt5.qtwebkit-dbg
What am I missing here? Note that the project explicitly requires the following in its README:
Qt 5.5+
PyQt5.6+
Furthermore, I understand that webengine and webkit are two different things (I was giving it a stab). I can't find any Webengine for PyQT5 anywhere in the official Vivid repository. I tried installing libqt5webengine5-dev and libqt5webengine5 from https://launchpad.net/~ethereum/+archive/ubuntu/ethereum-qt packages with the same result, perhaps I need to add something to Python path. Can anyone lend a hand (Im normally a .NET developer :/)?
ive been trying to run an application that was written on a Linux machine (and works without any issues), on my Mac running OS X El Capitan. the program utilizes PyQt4(4.11.4) and PySide (1.2.4), using Python 3.4.2. I created a virtualenv to guarantee that everything runs on the correct version of python. i have sip installed as well. However when i actually try to import anything from PySide it gives me the following error:
Traceback (most recent call last):
File "GUI.py", line 17, in <module>
from PySide import QtCore, QtGui, QtNetwork
ImportError: dlopen(/Users/mksmasr/.pyenv/versions/3.4.2/envs/pubdatapy34/lib/python3.4/site-packages/PySide/QtCore.so, 2): Library not loaded: #rpath/libpyside.cpython-34m.1.2.dylib
Referenced from: /Users/mksmasr/.pyenv/versions/3.4.2/envs/pubdatapy34/lib/python3.4/site-packages/PySide/QtCore.so
Reason: image not found
i cant seem to figure out the issue even after reading other SO posts and trying everything suggested.
when i run python at the command line and import PySide it imports it without an issue, the problem arises when trying to access anything inside of the PySide directory.
ive installed everything from source,it didn't work, so i tried pip,same issue, then i tried homebrew, and same issue. is the issue possibly PySide and python3.x compatibility?
I would appreciate any help!
I got it to work.
First, following this thread here
This gave the option of using PySide 1.2.2 or building 1.2.4 from scratch.
I settled for 1.2.2:
pip install -U PySide==1.2.2
After that, when trying to import PySide libraries, I got errors complaining about
unsafe use of relative rpath
To fix those I followed this advise
In a nutshell: I checked the libraries for relative links like this:
otool -L /Library/Python/2.7/site-packages/PySide/QtCore.so
Then I used install_name_tool -change ... as outlined in above link to re-link the two relative libraries in there to "/usr/local/...". E.g.:
sudo install_name_tool -change libshiboken-python2.7.1.2.dylib /usr/local/lib/libshiboken-python2.7.1.2.dylib QtCore.so
sudo install_name_tool -change libpyside-python2.7.1.2.dylib /usr/local/lib/libpyside-python2.7.1.2.dylib QtCore.so
Rinse and repeat for all the .so files.
This got PySide 1.2.2 working on El Capitan for me.
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.