How to avoid .pyc files from executable generation

34 views
Skip to first unread message

Marcos Albuquerque

unread,
Apr 23, 2024, 3:57:16 PMApr 23
to PyInstaller
Dear PyInstaller Support Team,

I hope this message finds you well. I'm currently working on a project where I'm utilizing PyInstaller for generating executables from Python scripts. During this process, I noticed that PyInstaller includes .pyc files in the PYZ file.

I understand the necessity of .pyc files during the compilation process, but for deployment purposes, I would prefer not to include them in the final executable.

Could you please provide guidance on whether it's possible to exclude .pyc files from being added to the executable during the generation process? If it's possible, I would greatly appreciate any instructions or pointers on how to achieve this.

Thank you very much for your assistance. I look forward to your response.

Best regards,
Marcos Albuquerque.

Elliot Garbus

unread,
Apr 23, 2024, 4:19:38 PMApr 23
to PyInstaller
Pyinstaller works by bundling the .pyc files.  If you want to hide your source code more complely you could compile some of you python modules with Cython to c.  See: https://pyinstaller.org/en/stable/operating-mode.html#hiding-the-source-code

Marcos Albuquerque

unread,
Apr 23, 2024, 5:26:32 PMApr 23
to PyInstaller
Does pyinstaller need the pyc even if we don’t specify the one file parameter?

elli...@cox.net

unread,
Apr 23, 2024, 5:41:31 PMApr 23
to pyins...@googlegroups.com
PyInstaller works by bundling your code (your .pyc files), your dependencies, and a python interpreter.    When you run the exe, your .pyc files are being run on the python interpreter.  

From: pyins...@googlegroups.com <pyins...@googlegroups.com> on behalf of Marcos Albuquerque <marcosrob...@gmail.com>
Sent: Tuesday, April 23, 2024 2:26 PM
To: PyInstaller <pyins...@googlegroups.com>
Subject: [PyInstaller] Re: How to avoid .pyc files from executable generation
 
--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/a189bf36-5031-4b8f-9df0-9bcee6f6e87an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages