Convert Your ‘.py’ to a ‘.exe’ File with Just 2 Commands

Convert Your ‘.py’ to a ‘.exe’ File with Just 2 Commands

In the previous post, we coded a Python script together which made it easier to stream Youtube videos in VLC.

Today, we will convert that “.py” file to a “.exe” file, so that you need not open the code in the editor and then run it each and every time. Also, you can just share the “.exe” file with anyone and they do not even need to install Python, because all the required modules are included in the “.exe” file.

You can find the .exe file in my Github repo here.

Let’s get started!

Step 1:

Install the “pyinstaller” library.

pip install pyinstaller

Step 2:

Go into the directory where your “YT_VLC.py” file is located. Press the “shift⇧” button and simultaneously right-click at the same location.

Click on “Open Power Shell Window here”.

Step 3:

Type the command given below in that PowerShell window and hit Enter.

pyinstaller --onefile --windowed --icon=icon\vlc_yt.ico 'YT_VLC.py'

// --onefile --> makes sure that the files created are all together
// --windowed --> To prevent opening of console window
// --icon=icon\vlc_yt.ico --> For the icon of exe file, if not provided, it provides a default icon

As our file is teeny-tiny, it should be done in less than a minute. After the process ends, there will be 3 folders namely, “build”, “py_cache” and “dist” in your parent directory. Also, a “YT_VLC.spec” file is created.

In the “dist” folder, we get our “YT_VLC” exe file (default name of source file). You can copy your “YT_VLC” exe file and delete all other files and folders if you wish to, it will not effect your exe file.

Step 4:

Run the “YT_VLC” .exe file and add “-vlc” at the end of the Youtube video link and copy that link. It will play the video in VLC without any errors.

Note: You may observe that the command prompt opens along with VLC when a video is played. You can just close the cmd window or leave it as is and continue watching.

You can find the .exe file in my Github repo here.

Thanks for reading! I’ll see you in the next article, where I will discuss some other interesting topics, so stay tuned.

Share your thoughts and suggestions in the comment section. For any doubts, you can ping me at or find me on Twitter.