pyQt4 DLL load failed: The specified module could not be found - python

I have an issue using the pyQt4 library in Atom. I installed the package using the installation file from sourceforge. I have python 3.6 installed. This is the code I have now:
import sys
from PyQt4 import QtGui
Whenever I try to run this I get the following error:
File ".\test.py", line 4, in <module>
from PyQt4 import QtGui`
ImportError: DLL load failed: The specified module could not be found.
I already googled and found a few ways to fix this but none of the solutions worked for me. Here's what I have done so far:
-Confirmed all .dll files are in the main directory(no \bin directory)
-Confirmed both python and qt4 are 64bit.
-Created a an environment path in windows system pointing to qt4 directory
-Uninstalled and installed qt4 again
-Installed qt5 - got the same error.
-Confirmed python3.dll is present in python directory
Any idea what else might be the problem? Or perhaps I should just change to wxpython?
Thanks.

OK, I got it. I don't know why but I had to uninstall and re-install sip again.
I believe I installed pytq4 before installing sip and that didn't work well.
I uninstalled both pyqt4 and sip and installed sip -> pyqt4 in this order.
Hope this helps someone.

Related

Python - PyQt5 [PyQt5.QtWidgets import QApplication 'No Module']

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

Error in using PyQt4 with python 3.5.2 for running a PyMoskito example

I'm trying to get an example of PyMoskito running under Python 3.5.2 Win7 64 bit
This library needs PyQt4 which in turn needs SIP.
1- I installed SIP using pip3 install SIP which ended up successfully (with a notice to update my pip).
2- I even barely know Python. So I tried installing PyQt4 with a binary executable. The binaries provided at riverbankcomputing.com/software/pyqt/download are for python 3.4 so I downloaded an unofficial wheel from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4 with a name PyQt4-4.11.4-cp35-none-win_amd64.whl. Then I cd'ed into the respective directory and installed it with pip which ended up successfully.
Now, I don't know what is the standard procedure for testing if a library is working. So I ran setup.py from the main directory of library and I assumed it set things up. Then I ran an example from examples folder and I get this error
Traceback (most recent call last):
File "C:\Users\****\Documents\Python Libraries\pymoskito-master\pymoskito-master\examples\ballbeam\main.py", line 3, in <module>
from PyQt4 import QtGui, QtCore
ImportError: DLL load failed: The specified module could not be found.
I assume python could NOT find the PyQt4 dependencies. I searched stackoverflow and non of the solutions worked. Here is what I tried so far:
There is NO /bin directory in C:\Python35\Lib\site-packages\PyQt4. So all dlls are already in the \PyQt4 directory
I added this directory to System PATH env. var. Same error occurs
I appended this directory to sys.path and tested it. Same error occurs
I created a \bin directory and copied all \PyQt4 into it. Then added it to PATH. Same error occurs
After that, I installed python 2.7 and PyQt4 from riverbankcomputing but not SIP. I still have the same problem
I really don't know what else should I do. I'm actually frustrated by all the mentioning of whether OP is using Python 2 or Python 3 or QT4 or QT5 or x86 or x64. I believe backward compatibility should be the minimum of a programming language and this is definitely a mess for Python
The short answer, I believe is that you have pyqt4 (a python interface to the qt4 library), sip (an automated c++-to-python communication library) but not qt4 itself (the UI library). qt4 is it's own monolithic c++ project with its own build and dependency problems.
You may be able to find the various pieces at http://www.lfd.uci.edu/~gohlke , but I would recommend installing the Anaconda distribution of python ( https://www.continuum.io/downloads ), which provides binary packages for things like qt4 and pyqtgraph, the former of which is installed by default, the latter requiring a command like
conda install pyqtgraph
After this, pip install of pymoskito should work.
There is also mention in the readme of vtk, but it is not in the requirememnts. vtk is also a monolithic c++ library and hard to build, but conda has that too, albeit not in the default channel for py35:
conda install vtk -c menpo

Setting up IPython Qtconsole with PyQt5

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...)

Setting up PyQt4 for win7

This is dumb, but I've just installed python and PyQt4 on my win7 laptop. However, when I try to import PyQt4, python can't find that module.
I followed the directions here:
http://qt-project.org/doc/qt-4.8/install-win.html
I've set up the Path environment variable. I ran the configure but my lib dir is still empty. I'm just not sure what I'm missing. Any help would be appreciated.
Cheers.
You need to install PyQt4, not Qt4.
http://www.riverbankcomputing.com/software/pyqt/download

Cannot import PyQt4.QtGui

I have a working Python 2.6 install and just installed the PyQt4 built for Python 2.6 (available at http://www.riverbankcomputing.co.uk/software/pyqt/download). When I try to import PyQt4.QtGui I get the following error:
ImportError: DLL load failed: The specified procedure could not be found.
I'm on Windows 2k8 64-bit, but my Python install is 32-bit.
Add the the PyQt4 directory containing Qt's applications and DLLs to your PATH environment variable. In PowerShell, provided you didn't change any of your install paths, that'd be
$env:path += ';C:\Python26\Lib\site-packages\PyQt4\bin'
I found a solution on another forum that worked for me. I needed to copy QtGui4.dll and QtCore4.dll into the ...\Python2.7.1\Lib\site-packages\PyQt4 directory. Note, I left the original in the bin directory.
I had installed PyQt4 from a .whl file (from the unofficial windows binaries) and got the same error.
I did what the answers suggested: checked that I installed the correct version, put my PyQt4 directory in the PATH environment variable and had QtCore4.dll and QtGui4.dll, however none of these worked.
The answer was to try and open the designer.exe program: it also had an error, but this time specified which DLL file was missing (it said msvcp140.dll is missing from your computer)
I then downloaded it off dll-files.com and put it in the PyQt4 folder (C:\Python35\Lib\site-packages\PyQt4) and it worked.
I hope this helps !
Are you sure you installed Python x64 ? By default, the Python website makes you download the x32 version, you need to go to this page to download the x64 version and then it will work. I had the same issue and it was fixed this way.
https://www.python.org/downloads/windows/
Hope that will help someone.
Cheers,
Chris
If this does not works, try search for QtCore4.dll, QtGui4.dll, etc. in your paths set in PATH environment variable. In my case I found some qt dll in c:\windows\system32, caused the same error message. I've deleted the dll files, and problem solved. 'C:\Python26\Lib\site-packages\PyQt4\bin' was in my path, but that was not enough.
Neither of the these solutions worked for me. I had Python 3.1 x64 with PyQt 4.8.2-1 x64 on my Windows 7 x64, but uninstalling them and installing the x86 versions of Python 3.1 and PyQt solved the problem for me.
Download the program from http://www.dependencywalker.com to see if there was missing dll.
You need to point the program to the QtGui.pyd file from PyQt.
My case was using MSYS2's mingw-w64-x86_64-python3-pyqt4, it needed libpython3.5m.dll while pacman was already at python3.6
I usage Linux ubuntu 14.04,firstly, Cannot import PyQt4.QtGui because access module PyQt4 not Available in group permission..
if call interpreter:shell>> python not available module QtGui, but if i call interpreter sudo python available QtGui.So, I solved this error , Change permisions folder package PyQt4 in my virtualenv,from property folder,change Owner and Group.
Its works for me :)
None of these solutions worked for me with 64bit Python 3.5. I ended up rolling back Anaconda to 4.1.1 (4.2.0 uses a Qt5 by default, which may or may not be the problem). I also had to install pyqt from a python 3.5 whl - http://www.lfd.uci.edu/%7Egohlke/pythonlibs/#pyqt4.
The binary file on the Riverbank website did not work for me, possibly it only works on Python 3.4?
I have installed pyqt with Anaconda several times, and I believe if it is done correctly the PATH does not need modification (it happens as part of installation) and DLLs do not need to be copied.
Did you verify that PyQt4 is for 32 or 64 bits?, I had the same problem I was using python 2.7.13 32 bit in Windows 10 and PyQt4 4.11 64 Bit, and changed PyQt4 for a 32 bit and it work immediately.

Categories