I developed a simple demo and packed it with pyinstaller

Thank you. You have successfully solved this problem and obtained the file path and name. Now I have another problem

from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
from PyQt5.QtGui import *
import sys

class Window(QWidget):
    def __init__(self):

        layout = QVBoxLayout()

        for arg in sys.argv:  # <1> sys.argv is a list of strings.
            l = QLabel(arg)


app = QApplication(sys.argv)
w = Window()

I want to add a program icon
It can be displayed normally

But I use pyinstaller to package and generate exe
pyinstaller -w test20.py

When the .MP4 video file on the desktop of the computer is opened through test20.exe, it will not be normal displayed. That’s why I can only copy one picture to the desktop,This is not the way to do it

Ah, that’s interesting – you when you run it as a packaged app, the exe file is the first argument? That’s kind of helpful. In that case you can just use sys.argv[1] or get the last argument in the list, e.g.

mp4_filename = sys.argv[-1]

That’s why I can only copy one picture to the desktop,This is not the way to do it

I’m not sure what you mean here?

Are you having problems setting the icon for the executable? In the PyInstaller tutorial Packaging PyQt5 applications for Windows, with PyInstaller it explains the problem – add the following to the top of your file.

from PyQt5.QtWinExtras import QtWin
myappid = 'com.qinhong.something'

and the icon should work as expected.

That tutorial also explains how to bundle the icons with your app.