I created a new Anaconda environment with Python 3.6. I installed PyQt5 with pip install PyQt5. I have this butt-simple program:
from PyQt5 import QtWidgets
#from PyQt5 import QtWebEngineWidgets
app = QtWidgets.QApplication([])
As written, it runs (and does nothing). If I uncomment the QtWebEngineWidgets line, it crashes. If I leave that line uncommented, but comment out the final line, it no longer crashes. In other words, it crashes when trying to create the application, but only if I previously tried to import QtWebEngineWidgets. Importing QtWebEngineWidgets itself doesn't cause a crash unless I try to create an application.
I'm running this on Windows 7. The crash is a "hard" crash: it's not a Python exception, but a Windows popup saying "Python has stopped working". The info says that the crash is in "atio6axx.dll". Googling around I see some hints that there could be some sort of conflict between Qt and my graphics driver, but I don't know how to debug it, let alone fix it. (I have an embedded graphics controller that shows as ATI Radeon HD 4250.)
conda list qt shows:
PyQt5 5.8.2 <pip>
What can I do to be able to use QtWebEngine successfully?
In my experience this issue has nothing to do with PyQt being installed using both pip and anaconda, although this would cause an problem too. If you only have pyqt installed on Anaconda the following code my cause a hard crash:
from qtpy import QtWidgets
from qtpy import QtWebEngineWidgets
app = QtWidgets.QApplication([])
We started experiencing this on a number of computers after an "upgrade" to windows 10, and noticing Spyder stopped working. It exited without an error message. The IT guys tracked it down to the graphics card.
Solutions: downgrade pyqt to version 5.6: conda install pyqt=5.6
I'm seeing this behavior on a windows 10 machine currently as well.
I use qtpy as well but have done this same example in just PyQt5.
Downgraded to 5.6 changes other behavior li
Related
I donwloaded PyQt6 using pip install pyqt6 and it had a bunch of errors so I uninstalled it and reinstalled it with pip install pyqt6 --user and the errors dissappeared. problem is trying to use it in VSCODe or any other ide doesn't work. When i write:
from PyQt6.QtWidgets import QApplication, QMainWindow, QAction, QMenu, QMessageBox VSCode gives me the error Import "PyQt6.QtWidgets" could not be resolved. Could someone walk me through what I may of done wrong please?
Try this in VSCode:
On the lower right of the VSCode window you should see the language
mode and version that VSCode is currently using. Something like "Python" 3.10.7.
If you HOVER over this text (like 3.10.7), VSCODE will display the
actual path used for that version.
If you CLICK on the version, you can change the LANGUAGE MODE and VERSION that is being used by VSCode in the window while editing (and executing) Python code. The language and version reflect the path to the library used.
In my case when I looked, the version had changed to a beta version I'd mistakingly installed earlier (3.11.03b). The version I was using when I installed PyQT6 was 3.10.7.
When I changed the version back to 3.10.7, suddenly everything worked again.
In my case, I had been moving things around in migrating from PyQT5 to PyQT6 and was now using a different file folder for my migrated code. I opened up a new VSCode Window and then my new PyQT6 folder, and I failed to notice that VSCode had chosen what it thought was the 'latest' version of the interpreter.
I have been attempting to learn PyQt5 in order to create GUI.
Pip installed the PyQt5 & the PyQt5.tools yet when I attempt to use it
using Visual Studio Code (while having the Python Extension of VS Code installed) I receive an error.
VS Code detects PyQt5 up to PyQt5.QtWidgets, yet it says no module inside QtWidgets named QApplication can be found.
Import Error of VS Code
On the contrary when it comes to the error, when I attempt to import QApplication from python.exe, no errors nor problems are presented.
Python.exe 'from PyQt5.QtWidgets import QApplication'
This leads me into thinking the problem resides at VS Code's doorstep..
Thanks for your time/answers.
open the cmd from start menu (Command Prompt)
type pip install pyqt5
type pip install pyqt5-stubs
install the integration of PyQt5 from VSCode Marketplace
if is it still not working try uninstalling PyQt5 (pip uninstall pyqt5)
and install it again
Search "PYQT Integration" on ur VS Code Extension shop
Install it
Set the configurations (ur pyqtdesigner path and pyuic etc)
this may help u
I had the same problem with lots of modules specially pytube . PyQt6 , It was all resolved when I changed my interpreter to python 3.11
I have built a GUI using PyQt5 and wanted to distribute it to other computers without Python installed by packageing it with pynsist. Unfortunately, when launching the shortcuts produced by the installer, the GUI does not open as expected and Python keeps crashing (even if Python is instlalled).
The console shows the following error upon crashing:
ModuleNotFoundError: No module named 'sip'.
This is due to from PyQt5.QtCore import *.
Unfortunately, when launching the .launch.py script on a computer with Python installed, everything works fine. I suppose this is because it then targets the installed version instead of the version included in the build of the GUI.
However, the shortcuts do not work, no matter if Python is installed, giving me the above error.
Any ideas how to fix this problem and make the shortcuts work on computers that do not have Python installed?
Thank you in advance!
When I first encountered this problem I simply added sip.pyd to my project-folder. You can find it under:
x:/path-to-python/Lib/site-packages/sip.pyd
but what realy solved my problem was using pyinstaller.
It automatically detects most dependencies and most of the time runs without complicated configurations.
pip install pyinstaller
pyinstaller main.py
# done
Sip is a separate package which PyQt5 requires. You can include it with your application by listing it in pypi_wheels=, as in the PyQt5 example:
[Include]
packages=listapp
pypi_wheels= PyQt5==5.6
sip==4.18
If you're using the latest version of PyQt5 (5.10.1), then the latest version of sip (4.19.8) should work with it.
Having some trouble setting up PyQt5 with Maya 2017. I have successfully installed PyQt5 on my mac and I can write standalone applications, but when I try to import PyQt5 modules in the Maya Script Editor using (for example)
from PyQt5 import QtWidgets
I get the following error :
Error: line 1: ImportError: file <maya console> line 1: No module named PyQt5
Not very experienced with using Python in Maya, is there some configuration I have to do? Also, does PyQt5 work with Maya 2016?
Maya won't ship with pyqt and you need to build your own version of pyqt for maya with mayapy. You local install of pyqt won't get loaded to maya so need to compile your version yourself. This link will give a insight of that http://justinfx.com/2011/11/09/installing-pyqt4-for-maya-2012-osx/. Although maya 2017 shipping with PySide2 and you can always use Pyside rather than pyqt.
like
from PySide2 import QtWidgets
Hope this helps.
If you want your scripts and UIs to work on either Maya 2016 or 2017 and above, I would suggest using the Qt.py package from Marcus Ottoson.
You can find it here.
You can just install it somewhere on your computer and add its path to the 'path' variable in your environment variables, you can then just do:
from Qt import QtWidgets, QtCore, QtGui
You can then write your UIs as you would in PySide2, and they will work on all versions of Maya because Qt.py is just a wrapper choosing the proper binding available on your machine, whether it is Pyside, Pyside2, Qt5, Qt4.
On an OSX 10.9, I have Qt5 installed. Later I installed Ipython, sip and PyQt5 all build from source. Now here is the problem: when I try to run ipython qtconsole, I have a bunch of errors related to the files in this directory (and its subfolders)
/Library/Python/2.7/site-packages/IPython/
followed by
ImportError:
Could not load requested Qt binding. Please ensure that
PyQt4 >= 4.7 or PySide >= 1.0.3 is available,
and only one is imported per session.
Currently-imported Qt library: None
PyQt4 installed: False
PySide >= 1.0.3 installed: False
Tried to load: ['pyside', 'pyqt']
I assume the problem is that I have PyQt5 instead of PyQt4. Is this the problem or I have missed some thing else?
Is there anyway that I can have qtconsole with PyQt5? If no, what is the easiest way to do so? (preferably, a method that does not involve having two versions of Qt library on one machine).
For sake of brevity I skipped posting the full error message. Please let me know if I should add them from better understanding of the situation.
The problem might be related to your python path.
I had almost the exact same problem. I had installed PyQt using Homebrew and I was getting the same error message. Finally what solved the problem was adding the following line to my .bash_profile:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
Since I am a beginner myself, I can't help you any further but I hope this solves the problem.
I know this is really old, but I was recently having trouble setting up PyQt5.
The problem was that PyQt5 would install, but some of the sub modules would not. For instance try
import PyQt5 #works
from PyQt5 import * # might fail
If the second command fails, then you have a problem with the PyQt5 setup, and you need to focus on that.
Specifically, ipython+qt will try to import the following
from PyQt5 import QtCore, QtSvg, QtWidgets, QtGui
If any of these sub-modules are broken/missing the qt console launch will quietly fail.
For me it turned out that the PyQt5 installer was failing to make the QtSvg bindings, which ipython tries to load from PyQt5. When you run the configure.py, use the -w option and you will see all the details of the build, allowing you to pinpoint where the install is failing.
In my case, a little googling and I found out that I was missing the QtSvg lib, which can be pulled in easily from the repos.
Setting environment variable QT_API=pyqt5 solved the same problem for me.
I had the same problem, though with the most recent brew of ipython the ImportError included PyQt5 (along with PyQt4 and PySide). So if it didn't work with PyQt5 before, it does now.
Adding the correct PYTHONPATH to .bash_profile fixed it for me, even in my virtualenv. (I don't have the reputation to up-vote or comment on oxtay's answer, where this would be more appropriate...)