Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16506

PyQt webbrowser become a virus

$
0
0

I'm trying to combine backend and frontend.

I've created a frontend using PyQt webbrowser:

from PySide2.QtCore import *from PySide2.QtWidgets import *from PySide2.QtGui import *from PySide2.QtWebEngineWidgets import *import sysclass MainWindow(QMainWindow):    def __init__(self, *args, **kwargs):        super(MainWindow, self).__init__(*args, **kwargs)        self.browser = QWebEngineView()        self.browser.setBaseSize(800, 600)        self.browser.setUrl(QUrl("http://127.0.0.1:8000/"))        self.setCentralWidget(self.browser)        self.show()def gui_main():    app = QApplication(sys.argv)    window = MainWindow()    app.exec_()if __name__ == "__main__":    gui_main()

The backend is using fastapi:

from typing import Unionfrom fastapi import FastAPIapp = FastAPI()@app.get("/")def read_root():    return {"Hello": "World"}@app.get("/items/{item_id}")def read_item(item_id: int, q: Union[str, None] = None):    return {"item_id": item_id, "q": q}def backend():    import uvicorn    uvicorn.run(app)

So far, everything is good. I can launch backend and start debugging:uvicorn backend:app

But when I tried to create a single executable using pyinstaller:pyinstaller --onefile main.py

The main.py just launches backend and frontend:

from backend import backendfrom gui import gui_mainimport multiprocessingif __name__ == "__main__":    p = multiprocessing.Process(target=backend)    p.start()    gui_main()

The resulting app keep poping up windows and exausted all memory.

I've tried to restart computer, but the issue remains the same.


Viewing all articles
Browse latest Browse all 16506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>