Unable to import QtGui, QtWidgets modules of PyQt5/PySide in WinPE - python

I'm developing a tool to be used in WinPE and have been facing an issue while using PySide2/PyQt5 in WinPE environment.
While importing QtGui, it says ImportError: DLL load failed while importing QtGui: The specified module could not be found.
But importing QtCore is successful.
If I use the same environment in another Windows machine it is successful.

I also developing a pyqt5 program run in winpe.
using pyinstaller convert it to exe and run successfully in a new win7 machchine.
when start at win10 pe the command line says below message.
The specified module could not be found.
I found one solution is using specific version of PyQT5 from below url
pip install PyQT5==5.9
https://stackoverflow.com/a/51821319/7324168

Related

pyinstaller - when freeze the app QtWebEngineWidgets throws dll error

I have a code that have QtWebEngineWidgets module from PyQt5. it works fine in raw form (.py) but throws the following .dll and openGL missing error when freeze through pyinstaller. PyQt5 and pyinstaller are both upto date.
Also, for your information, i am running this code on amazon c2 instance.
from the issue of Anaconda, the following command when run on the cmd, the error will be fix
set QT_OPENGL=desktop
solution in Anaconda Issues

PyCharm Error, ModuleNotFoundError: No module named 'PyQt5'

I installed python 3.7 and PyQt5 using pip install PyQt5 command. when I import the module in python console of pycharm, it is working alright but when I import it into my project files am getting the following error. I searched through the internet for possible solutions but are not working for me and I also think my problem is different from those that were already asked. any help?
from PyQt5 import QtCore, uic, QtWidgets
from PyQt5.uic import loadUi
from PyQt5.QtWidgets import QApplication,QDialog
import sys
UIClass, QtBaseClass = uic.loadUiType("projj/firstly.ui")
class MyApp(UIClass, QtBaseClass):
def __init__(self):
UIClass.__init__(self)
QtBaseClass.__init__(self)
self.setupUi(self)
self.setWindowTitle('developer in details')
self.pushButton.clicked.connect(self.on_pushButton_clicked)
self.pushButton_2.clicked.connect(self.on_pushButton_clicked_2)
self.pushButton_6.clicked.connect(self.on_pushButton_clicked_6)
and the error am getting is
Traceback (most recent call last):
File "C:/Users/pc/PycharmProjects/presents/Main.py", line 1, in <module>
from PyQt5 import QtCore, uic, QtWidgets
ModuleNotFoundError: No module named 'PyQt5'
I find out that I can just use the available tool in PyCharm which is the IDE am using for python. By just clicking the red underlined word PyQt5 in this case and a red bulb will appear to the left end of the line >> click the drop down that appear and select install package PyQt5. it installs the required staff again and everything works fine then.
It sounds like the Python Console and your project are running two different Python Interpreters.
When you start the Python Console the top line should list the interpreter it's using. This is the one you installed PyQt5 to.
Go to: File -> Settings -> Project: xxxxx -> Project Interpreter and change it to the one that's in your Python Console. (Note you may need to add another interpreter by clicking on the gear to the right of the text box listing the interpreters)
Installing PyQt5 like this worked for me:
python -m pip install PyQt5
You can try to reinstall PyQt5 like this:
pip uninstall PyQt5
python -m pip install PyQt5

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

PyQt5 Maya 2017

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.

PyQt Windows installer with Anaconda Python--PyQt4 not found; how do I troubleshoot?

Note: My first attempt at asking a question was confusing PyQt and pyqt_fit. I've preserved my first attempt below for archival purposes. It seems clear that PyQt should be a prerequisite to getting pyqt_fit working.
I installed PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe, available here. I see pyqt-4.10.4-py27_1.tar in \Anaconda\pkgs, and if I run the installer again, it tells me it's installed.
Unfortunately, it seems that iPython still isn't finding it:
In [5]: from PyQt4 import QtCore, QtGui
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-5a7197379ef6> in <module>()
----> 1 from PyQt4 import QtCore, QtGui
ImportError: No module named PyQt4
How can I troubleshoot why it's not finding this?
System specs
Python 2.7.9 :: Anaconda 2.2.0 (64-bit)
OS Name: Microsoft Windows 8.1
OS Version: 6.3.9600 N/A Build 9600
OS Configuration: Standalone Workstation
OS Build Type:
Multiprocessor Free
System Manufacturer: Dell Inc.
System Model: Inspiron 5547
First attempt at question
I installed PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe, available here, in the understanding that it would give me "everything needed for PyQt4 development except for Python itself." Instead, though, I'm finding that importing pyqt_fit and pyqt_fit1d is giving me errors seemingly related to compilation.
Summary
I'm trying to import these through the iPython prompt and iPython Notebook, and I have a hunch they're looking at somewhat different instances of pyqt*, but I don't know how to confirm this intuition.
When I tried to import pyqt_fit or pyqt_fit1d, I got a "DistutilsPlatformError: Unable to find vcvarsall.bat". I installed the Microsoft Visual C++ Compiler for Python 2.7, and hacked the registry a bit to get it to not complain about not finding vcvarsall.bat, but the compilation still fails.
It seems like working at the compiler level shouldn't be necessary if the installer worked. What am I not understanding?
Observed behavior from an iPython prompt
Typing "import pyqt[Tab]" suggests only pyqt_fit1d and pyqtconfig.
import pyqtconfig fails with ImportError: No module named sipconfig. (I believe this used to work only at the iPython prompt before I installed the VC++ stuff.)
import pyqt_fit1d fails the first time with ImportError: Building module pyqt_fit._kernels failed: ["CompileError: command 'C:\\\\Users\\\\<username>\\\\AppData\\\\Local\\\\Programs\\\\Common\\\Microsoft\\\\Visual C++ for Python\\\\9.0\\\\VC\\\\Bin\\\\amd64\\\\cl.exe' failed with exit status 2\n"]. Complete backtrace here.
On subsequent attempts, it fails with ImportError: cannot import name functions in C:\Anaconda\lib\site-packages\pyqt_fit__init__.py.
import pyqt_fit behaves exactly the same.
Observed behavior from an iPython notebook
Typing "import pyqt[Tab]" in a new notebook suggests only pyqtconfig.
import pyqtconfig gets ImportError: No module named sipconfig, as at iPython prompt.
import pyqt_fit1d fails with ImportError: No module named pyqt_fit1d -- Note difference from iPython prompt above
import pyqt_fit fails with the same ```ImportError: Building module pyqt_fit._kernels failed: ["CompileError: command 'C:\\Users\\\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2\n"]
pyqt_fit appears to be a completely separate package, not maintained by the PyQt developers.
To use PyQt4, you want to try from PyQt4 import QtCore, QtGui. I suspect the auto-completion of your python terminal just doesn't know about the PyQt package you installed.
If you want to install PyQt4, you can do so using anaconda.
1. Go to Anaconda-> Environments
2. You will get a list of modules already installed. Type PyQt in search bar of variables windows
3. Select Not Installed from the drop down
4. From the list, click on anyqt and pyqtgraph
5. Click Apply
It will automatically install PyQt and you won't get this error: ImportError: No module named PyQt4

Categories