QsciScintilla on Pyqt4 for python35 error (unofficial whl) - pyqt4

I want to use pyqt4 on python35. However, the latest official release supports py=<34
So I found this university website https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
which unofficially extended support for later versions including python35
My problem is that QsciScintilla is not working. I tried to run this code:
import sys
from PyQt4.QtGui import QApplication
from PyQt4 import QtCore, QtGui, Qsci
from PyQt4.Qsci import QsciScintilla
if __name__ == "__main__":
app = QApplication(sys.argv)
editor = QsciScintilla()
editor.show()
sys.exit(app.exec_())
The window becomes unresponsive then crashes:
Process finished with exit code -1073740771 (0xC000041D)
The reason I want to use pyqt4 on python3.5 is that I have a quit big application built on pyqt4
and I want to upgrade python version of the project to 35

I moved to PyQt5. It is always not a good idea to use an unofficial package.

Related

How to reliably convince matplotlib to use PySide2 backend when running from Anaconda (Spyder)

I am creating a PySide2 application which uses matplotlib. I am running this application from Spyder in an environment with PySide2 installed. This is causing the application to be run from the iPython console. Somewhere along the line, PyQt5 is imported, which I am attempting to purge in order to convince matplotlib that I really do want to use PySide2, NOT PyQt5. Something like following was working until very recently and I am not really sure why it has stopped, but safe to say this method is unreliable. How can I absolutely convince matplotlib that I am wanting PySide2?
I have tried setting the environment variable QT_API in the operating system (Windows 10), but in this case Spyder itself refuses to open.
import sys
import os
ps = list(filter(lambda x: 'PyQt5' in x, sys.modules))
for p in ps:
print(f"purging module {p}")
sys.modules.pop(p)
# matplotlib.__init__ uses this
os.environ["MPLBACKEND"] = "PySide2"
# matplotlib.backends.qt_compat uses this
os.environ["QT_API"] = "PySide2"
import PySide2.QtCore
assert "PyQt5.QtCore" not in sys.modules
assert "PySide2.QtCore" in sys.modules
# rcParams has the right idea
from matplotlib import rcParams
print(rcParams["backend"])
# qt_compat has the WRONG idea!
import matplotlib.backends.qt_compat as qt_compat
print(qt_compat.QT_API)
# The FigureCanvasWidget is of the wrong (PyQt5) type
from matplotlib.backends.backend_qt5agg import FigureCanvas
import inspect
print(inspect.getmro(FigureCanvas))
To answer this question, the reason that it stopped working was because I had set 'activate support' for Matplotlib graphics in the ipython tab under Spyder settings. After unchecking this, the above works.

How to change the source of python used by atom runner or script in Atom?

I want to run python code with Kivy by atom-runner or script, but when I run the simple any codes with Kivy, I got ModuleNotFoundError. I checked python path by
import sys
print(sys.prefix)
which prints ''/Library/Frameworks/Python.framework/Versions/3.7''
I guess I need to use Anaconda's python because I can run Kivy app on terminal and terminal uses python3.7 showing Anaconda.inc things.
But I can not find where to write path of python in Atom.
I tried pip install Kivy and it worked but nothing changed in Atom. And Kivy3 is in Application folder.
Just in case, my Kivy codes is this
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
class IntroKivy(App):
def build(self):
return Button(text="Hello, World!")
if __name__ == "__main__":
IntroKivy().run()
It will be perfect if I can run this codes without using terminal as it is faster and quick.
Best

Can't exit PyQt application on 3.7.4 and Spyder

Running on Windows 10 64 bit and Python 3.7.4 (no Anaconda), the basic script from Terminate PyQt Application
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtCore import QSize
class HelloWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(640, 480))
self.setWindowTitle("Hello world")
centralWidget = QWidget(self)
self.setCentralWidget(centralWidget)
gridLayout = QGridLayout(self)
centralWidget.setLayout(gridLayout)
title = QLabel("Hello World from PyQt", self)
title.setAlignment(QtCore.Qt.AlignCenter)
gridLayout.addWidget(title, 0, 0)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
mainWin = HelloWindow()
mainWin.show()
sys.exit( app.exec_() )
does not exit when starting from Spyder.
The IPython console simply "idles", but never returns. Running the script from the command prompt (i.e. 'python script.py') works OK.
Switching back to a fresh install of Python 3.7.2, everthing works as expected. The IPython version is in both cases 7.7.0.
In both cases (3.7.2 and 3.7.4) all modules including Spyder had been installed via pip.
Any idea why that is? Is it a Spyder related issue?
Keeping the Graphics Backend as not "Inline" is creating this problem.
Either change the graphics backend as,
Tools -> Preferences --> IPython Console -> Graphics --> Graphics Backend as Inline
Or Restore the default settings of the Spyder Environment. Which can be done by,
Tools -> Preference --> Reset to Defaults.

DLL Load Fail While Importing QtCore, QtGui

guys
I recently heard about PyQt4 and decided I should give it a try, however, importing gave me some errors. When I tried importing QtCore and QtGui, I received this error:
from PyQt4 import QtCore, QtGui
ImportError: DLL load failed: The specified module could not be found.
I am using python 3.6.0 on my windows 32 bit computer
I installed pyqt4 by using
pip install pyqt4-4.11.4-cp36-cp36m-win32.whl
To solve this problem I looked into my site-packages and I did see
You should use PyQt5. I know it doesn't have QWebView, but it has a extra module called QWebEngineView. You can install it by running this in the terminal:
pip install PyQtWebEngine. This is the code I use:
import sys
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import QApplication
url = "https://stackoverflow.com/"
app = QApplication(sys.argv)
web = QWebEngineView()
web.load(QUrl(url))
web.setZoomFactor(2)
web.zoomFactor()
web.show()
sys.exit(app.exec_())

PyQt4 and Python 3.2 on OS X

I've successfully installed Qt4.7.3, Python 3.2, SIP, & PyQt4. Or I think I do? I can
import PyQt4
without any issues but when I try to run this:
#!/usr/bin/env python3
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
widget.resize(250, 150)
widget.setWindowTitle('simple')
widget.show()
sys.exit(app.exec_())
I get this error:
Traceback (most recent call last):
File "./simple.py", line 6, in <module>
from PyQt4 import QtGui
ImportError: cannot import name QtGui
I've checked the paths and they seem to be fine but when looking for the components I can't find them? I do have libQt.a and libQtCore.a where I assume those components would be. I just can't seem to access them.
Any ideas?
Thanks.
If you use #!/usr/bin/env python3 you can not be sure which version of python starts up. For testing you should directly use python3.2!
Since import PyQt4 works and from PyQt4 import QtGui not, it is likely that the files in the PyQt4 module directory are misplaced.
The QtGui.so file needs to resist directly in the PyQt4 directory!
On GNU Systems this directory can be found at /usr/lib/python3/dist-packages/PyQt4/ and on Windows at %SystemDrive%23/Python32/Lib/site-packages/PyQt4/.
This might help finding the directory on Mac OS:
import PyQt4
print(PyQt4.__file__)

Resources