Use PyQt5.QtWebEngineWidgets on Windows: is it possible? - python-3.x

I am trying to build an app in PyQt5 (version 5.6+) in Python 3.6. It contains a web browser, using QtWebEngineWidgets.
It works fine on Mac, however, there are problems on Windows.
When I run the code on Windows and import the module:
from PyQt5 import QtWebEngineWidgets
I get the following error:
ImportError: cannot import name 'QtWebEngineWidgets'
Now, reading some forums it looks like PyQt5.QtWebEngineWidgets is not available for Windows, yet. Is it correct?
How can I have a web browser window, then?
I found online I could use QtWebKit, but according to here it seems QtWebKit was removed in Qt5.6.
So what? Do I have to downgrade PyQt version?
I can't go under 5.6 in Python 3.6 anyway. Do I have to change Python version as well?

you can try one of these solution ,
install old version :
pip install PyQt5==5.11.3
or install :
pip install PyQtWebEngine

u can download PyQt5.6 from here:
https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.6
QtWebKit got deprecated upstream in Qt 5.5 and removed in 5.6. Beacuse The QtWebEngineWidgets module is better than QtWebkit.
The example directory has many examples about QtWebEngineWidgets

Yes, its possible to use QtWebEngineWidgets on Windows.

Related

PyInstaller weird PyQt5.sip import causes a failed EXE [duplicate]

After upgrading to python-pyqt5 5.12-2 I get this error when I try to import from QtWidgets
from PyQt5.QtWidgets import *
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
Any idea on how can I solve this issue?
The reason is a backward incompatible change in PyQt-5.11
In geoptics this fix works on old and new versions:
try:
# new location for sip
# https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
from PyQt5 import sip
except ImportError:
import sip
As suggested here pyuic5 - ModuleNotFoundError: No module named PyQt5.sip
Try uninstalling and re-installing all PyQt related libraries:
pip uninstall PyQt5
pip uninstall PyQt5-sip
pip uninstall PyQtWebEngine
Then install them again, this will fix:
ModuleNotFoundError: No module named 'PyQt5.sip'
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
PPS.:If you got problems uninstalling the libraries, go to your Python folder, like C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python<PYTHON-VERSION>\Lib\site-packages and manually delete the PyQt folders, them uninstall everything and install again (Make sure you have the latest Python version and upgraded your pip too)
If you're building sip and PyQt5 from source using make files, make sure to check PyQt5 install docs. In particular,
Note
When building PyQt5 v5.11 or later you must configure SIP to create a
private copy of the sip module using a command line similar to the
following:
python configure.py --sip-module PyQt5.sip
If you already have SIP installed and you just want to build and
install the private copy of the module then add the --no-tools option.
You should add PyQt5.sip to hidden imports; that should solve the issue.
I repaired this problem
This problem occurred when upgrading pyqt5 version 5.15.0
There was no problem when I reverted to the previous version.
I have
python -V: 3.7.4
PYQT5 5.14.1 and PYSIDE 5.14.1 works fine
In addition to the answer provided by Tadeu (https://stackoverflow.com/a/58880976/12455023) I would also suggest checking version of your libraries to make sure that they match.
Use pip show <library_name>
This will help you to make sure that no earlier installation is conflicting with your current installation.
In place of library_name use PyQt5, PyQt5-sip, PyQtWebEngine. If any of them is present in the system, then use pip uninstall <library_name>==<version_number> to remove that library.
Once you made sure that no other versions of these libraries are there, then you can reinstall the preferred version of that library.

Pandas install or import in IBM SPSS Statistics Version 26

I have installed the latest version of IBM SPSS Statistics(Version 26) which has pre installed python 3.4 and 2.7. i am trying to use version 3.4 python. i am able to import modules like pip , sys , os etc. i tried pandas the same way. i am unable to do so. getting error no module found. Hence going through our forum and IBM support did the following changes.
received the following error
1) tried pointing the site-packages via
import sys
# Assuming windows and standard python folder here.
sys.path.append(r"D:\Python34\Lib\site-packages")
2) changed the path in the settings of SPSS
3) Tried installing pip in the below folder as suggested in the forum but got message i have already installed the updated version.
C:\Program Files\IBM\SPSS\Statistics\Subscription\Python3
4) following versions of python were installed
have tried what i could. Need your expertise help to fix the same which will help me to install/use modules needed for SPSS. Thanks.
This is going to be painful to explain, I'll do my best.
As far as I can tell, you're on windows. Usually when we need a new package, we just open cmd and type pip install xxx (assume you added python to path when installing it). The reason that this works, is because when you type pip install xxx in cmd, windows recognize pip to be a command because python path is in system variables. Windows know that I can execute pip install with this python path.
However for SPSS python (3.4), that python had a different path in the system. Thus when you only have the 3.7 or 3.8 python in path, windows cannot install package to you 3.4 python, and I'm not sure if you can have more than one python path in system.
In order to fix this, you need to first figure out what's the path to your 3.4 python, then in this page you can follow the instruction to remove your 3.7 or 3.8 python in path, and add your 3.4 path, then you can do pip install xxxx for whatever package you want
I did the same thing with a arcgis python distribution, hope this works for you. If the attached page does not work, just google add python path to windows and look for a instruction that works on you PC
Oh and the reason that you can import pip, sys and some other package but not pandas, is because python is 'battery included', it comes with tons of packages pre-installed for additional functionality, but pandas is not one of them.
Fixed it since my ananconda had version 3.7 .i created virtual environment and installed 2.7 python with anaconda package. Pointed SPSS to the 2.7 folder and was able to import pandas.

How to get QtWebEngineView in ptqt5 using python 3.4 on windows?

I tried pyqt 5.5 but it's showing unused import...unable to find keyword qtwebengineview or qt webenginewidgets Thanks..appreciate your time
You can fix the issue now by updating to pyqt5.9,
pip install PyQt5 --update
should do the trick. Once it's installed you'll need to import it with:
from PyQt5.QtWebEngineWidgets import QWebEngineView

PyCrypto for Python 3.4 on Windows 8.1 cannot find winrandom module

I've been trying to install Paramiko in a Python 3.4 virtual environment. I tried pip installing, as well as easy_installing with pre-built binaries and neither worked. Suggested Here. Both kept saying that winrandom is not a valid Win32 application.
I found that is is a problem with PyCrypto, and not Paramiko directly, so I installed from source and pre-built binaries and still can't get it to find/use a module called winrandom.
Have any of you solved this problem? It's very frustrating.
From the same link, change nt.py (...\Lib\site-packages\Crypto\Random\OSRNG\nt.py)
change
import winrandom
to
from . import winrandom
Not really sure if this is helpfull for you guys, but i got the problem that I was not able to install winrandom for python3.4
With the foolowing link, I fixed my problem
https://github.com/dlitz/pycrypto/commit/10abfc8633bac653eda4d346fc051b2f07554dcd
2.6.1 has a relative import that's fixed in 2.7. Probably all you need to do is fix that import in Crypto\Random\OSRNG\nt.py

Why PyCharm can't import Gtk? [duplicate]

I'm using PyCharm 2.5 on Ubuntu 11.10, trying to develop an application using PyGObject 3.0 on Python 3.2.2. I've installed the Ubuntu package python3-gobject, and when I run my code, it works exactly as expected.
However, PyCharm can not seem to find any of the PyGObject modules. It says Unresolved refrence: 'Gtk' when I hover over Gtk in my import statement, and of course none of the auto-completion works.
This is my code:
#!/usr/bin/env python3
from gi.repository import Gtk
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
I've even tried making a python virtual environment and then installing PyGObject from source into it, and then even tried making symlinks from all the .py files in site-packages/gi/overrides to site-packages/gi/repository, all with no luck.
Any advice would be greatly appreciated!
Position the text cursor inside the redlined Gtk in:
from gi.repository import Gtk
hit Alt + Enter and choose "Generate stubs for binary module"
In Gtk+ 3 Python bindings to binary modules are generated dynamically using *.typelib databases. The dynamic importer for accessing all the modules is located in gi.repository. PyCharm cannot detect these modules using its code insight, because they require special handling.
I've filed a feature request for this issue: PY-6932. Feel free to vote for it.

Resources