Why PyQt 5 doesn't working in Google Colab? - python-3.x

import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
when i run the code google colab gives Your session crashed for unknown reason error. Can somebody please help me?

Just take a look at this image of logs and u will see that Google Colab can't support the GUI app using qt

Related

How to make an Web Browser with Python 3.8

I trying to find out how to make an Web Browser using Python 3.8, but nothing works. Most of the tutorials or articles I find just opens links in Firefox (I use Firefox) using the webbrowser module. The rest of them use PyQt, which for some reason just doesn't work on my computer (I'm using Windows 10). When I import PyQt from PyQt5.QtGui import QApplication it says ModuleNotFoundError: No module named 'PyQt5.QtGui'. I'm trying to make it simple, just an search bar for getting the urls and a place to display the webpage. Maybe something like this:
Mozarella Ashbadger browser made with PyQT
PyQt5 went through some changes in the last few years which might be causing your issues.
I have tested the following method recently as part of a package I recently made with a integrated webbrowser, so as of writing (October 2020) it will work.
First you need to also install an additional module PyQtWebEngine. then the following code should open a single page.
import sys
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
web = QWebEngineView()
web.load(QUrl("https://stackoverflow.com/"))
web.show()
sys.exit(app.exec_())
Anything more than that will require some UI work, but it should be easier now that you have the web part of it handled.

How to remove the error message: 'unused import statement' in Android Studio?

I am working in Android Studio, and while importing these packages
import android.util.Log;
import com.mesibo.api.Mesibo;
the following error message occurs:
unused import statement
import android.util.Log;
import com.mesibo.api.Mesibo;
Any ideas on how to resolve this error message? Your help would be greatly appreciated!
This is a warning message not an error message.
This message indicates that a library you've imported is potentially not being used within your current file as indicated by the grey color associated with said import. With that being said, it isn't harmful for there to be an unused import statement. Although, if you truly aren't using the built-in Android logger or your custom API then feel free to delete the import statements.
This warning message likely occurred because of the Optimize imports on the fly option selected within your Android Studio IDE. For more information check out the JetBrains documentation for additional IDE settings.
Hopefully that helps!
What I did was that I imported the git repository file from the official mesibo page, with the git tool, opened the sample project and recompiled the project, add the json file from firebase and ready to compile the app without probes thanks for the answer and I share my experience about this error

OpenCV with watson studio

I am trying to use watson studio for detecting images taken from webcam. I use opencv to capture the video first and then read it frame by frame. Following is small part of the code to checck if video is getting captured.
import cv2
cap = cv2.VideoCapture(0)
cap.isOpened()
This code returns True when I use it with python 2.7 locally but this does not work at all and returns False when I use it in the notebook for watson studio. I am not able to understand why this is happening
I think this is not possible.
Given, cv2 would try to open/locate camera at the runtime attached to notebook and
not the user's camera who is browsing the notebook/url.
The cv2 running in runtimes have no way to talk to user's browser/camera.
Now when i say runtime, it can be spark service or Environment attached to the notebook.
I would suggest to capture images and then upload to COS to do further processing of those images using cv2 if thats the usecase.
Thanks,
Charles.

QWebSettings in PyQt5 (version 5.6.0)

I have PyQt5 (version 5.6.0) installed via Anaconda on my Mac (OS X 10.12.2). Now I would like to re-use an older script that used QtWebKitWidgetsand QtWebKit, however, these two packages seem to have been removed in PyQt5.6.0. I already know that QtWebKitWidgets was replaced by QtWebEngineWidgets (which all works fine for me), but in my old code, I was importing QWebSettings from QtWebKit, i.e.
from PyQt5.QtWebKit import QWebSettings
But not I get an ImportError here:
ImportError: cannot import name 'QtWebKit'
According to the PyQt documentation,
QtWebEngineWidgets contains classes for a Chromium based implementation
of a web browser. This supercedes the QtWebKit module and provides better and up-to-date support for HTML, CSS and JavaScript features. However it also consumes more resources and doesn’t give direct access to the network stack and the HTML document via Python APIs.
But where do I find QWebSettings? Can anyone please tell me where I can find QWebSettingsnow, or how I can add the package QtWebKit?
Any help would be very much appreciated.
The correct import statement is:
from PyQt5.QtWebEngineWidgets import QWebEngineSettings

Trouble importing HTTPTokenAuth from flask_httpauth

I am trying to use token authentication for a Flask project.
from flask_httpauth import HTTPBasicAuth # works
from flask_httpauth import HTTPTokenAuth # does not work.
I get the following error
ImportError: cannot import name HTTPTokenAuth
I tried
pip install flask_httpauth --upgrade
But it claims everything is up to date. (Flask-HTTPAuth==3.1.1)
The docs suggest this is the proper way to import it, but for some reason it is not working. Any ideas how I can get the token auth to import?
Edit:: I deleted and recreated the virtual environment I was using.
I am using python anywhere.
The problem persists. I discovered an older version of Flask_httpauth is loaded by default (v2.2.0 instead of v3.1.1). I went into the site packages and saw the HTTPTokenAuth is there and should be called.
I tried doing
import flask_httpauth
print (flask_httpauth.__version__)
to check the version being called by my app, but that doesnt work for all python packages, and it seems flask_httpauth doesnt have that functionality.
There are no errors displayed where I have the virtual enviorment linked on the web tab of pythonanywhere.
PythonAnywhere dev here, just reposting the solution that was discovered from #ExperimentsWithCode's forum post. The problem was happening when the code was being run from the editor on PythonAnywhere. This is separate from the configuration that is done on the "Web" tab where the virtualenv was specified: people can run any code they want from the editor, regardless of which web app it's associated with, or even code that's not associated with a web app.
So the solution was what #Miguel suggested: use a shebang.

Resources