Why does pyinstaller create so large exe files? [closed] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
While I was converting my python game file to exe file using pyinstaller, the size came out to be very large(300 MB). I also had used upx which made file exe file even more large(317 MB). The python game file is an offline game. Can anyone provide a solution to this?

Pygame is optionally dependent on numpy, scipy, and PIL. (Or maybe the scipy and PIL come from being optionally dependent on numpy, it makes no difference here)
If you have those installed on your system, PyInstaller will bundle them with your executable. But you probably don't need them. (Unless you're using pygame.sndarray or pygame.surfarray, which are backed by numpy).
To exclude them, you can add the following to the excludes portion of your .spec file: ['numpy', 'scipy', 'PIL']
It looks like you could also do this as a command line option with multiple uses of the --exclude-module argument. See https://pyinstaller.readthedocs.io/en/stable/usage.html#cmdoption-exclude-module
Some people also get around this by using virtual environments.
But even assuming you have those 3 libraries bundled, 300 mb is quite large. If you're doing onefile mode, stop doing that for debugging, so you can see the folder names and files included with your project. That will give you more insight.

Related

How to share my python game with friends who don't have python or pygame [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Just finished making my first python game based on the space invaders game. Now I don't know exactly how to share it with my friends. I know that I should use py2app, but I haven't found good online instructions on how to do so.
This is how the project file looks like:
I'd appreciate it if someone could help me out.
pip install pyinstaller - this module can generate executables of python scripts.
Then simply run: pyinstaller main.py or whatever the main file is named and it will generate an executable including all needed modules (you can find the
generated package in new created dist folder).
You can try using Py2exe, which, as the name suggests, compiles Python programs to an executable format.
Edit: Just noticed you were using MacOS, here is a Py2app tutorial instead.

Can Python create a self contained package that can be deployed where python and pip is not installed? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Some programming languages provide capability t create a self contained packages that can run on any machine.
For example, dotnet core can self-contained apps per below:
https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained
The C# self-contained apps can be single large file, or a directory of all files required to run the application. The package can target Linux, mac or Windows.
In Python, what is the closest feature to self-contained app packages described above?
PyInstaller seems to be the current go to, and it works well in my experience. However, some people have reported that it has very large file sizes, but I've personally never found that to be a major issue.
If you use that, you would also probably need some kind of UI, but that's a separate issue in itself.

is it possible to make software using python only? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to make a small .exe file that will work in any PCs , is it possible to make and if yes then what is the procedure ?
Check this: https://github.com/brentvollebregt/auto-py-to-exe
It's an open source project called auto-py-to-exe. It's a GUI with PyInstaller internally, making more confortable alternative. It can also output a standalone file in contrast to other solutions.
Since you wrote a terrible question, I will write a terrible answer:
Yes, you can make .exe files in python. You need a package called "psutil" which can convert your .py files into .exe files AND convert them into executables for other operating systems as well. A .exe file only works on Windows, so some PC running a Linux Distro won't be able to run it.
Edit: pyinstaller is also useful when you want to just make a .exe

making a .exe from python including .txt files? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a python script that relies on over 400 .txt files (with HUGE dictionaries, so much so it needs to choose each one by itself and only load one at a time). How could I make an exe file from the python script that will come with the .txt files? I've looked at both pyInstaller and py2exe but nothing I see I understand/works for me?
Thank you in advance
EDIT: The text files have sensitive data in them, would it be possible for them to be only accessible by the python script itself?
You could also use the cx_freeze module to accomplish this. Similar to Moe's suggestion it also takes a --onefile flag I believe.
Here is a link to another stack question that is similar. The answer in there not only shows how to construct the setup.py file for cx but also error handling when it inevitably misses some dependencies.
EDIT**
Here is a link to an article about securing your data. I don't think that you can do it in any straight forward way so here are some suggestions.
first you could store your data in a non usual format. Such as bytes.
second there are programs to obfuscate the data. The link provided above discusses some.
Third you could host the data online and use some sort of encrypted key pair connection to securely acquire necessary data.
You can create the .exe file with pyInstaller or py2exe then use any installer like Inno Setup to package the created .exe file with the .txt files into a single installer package.
If you are using pyInstaller, you can use --onefile to make a single executable file for the code to use it for the above example.

Export Python script [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm using Blender and Python and want to give the .py file to other users to use my script... My script uses external modules (like NumPy) which will rise the errors (like can't find module xxxx).
Not all people can install NumPy (or even Python :D) as many Blender users are just artists.
Another note is that NumPy doesn't work with Blender (I install it in the system's Python, then delete Blender Python so it relies on the system Python).
If you want to distribute your code with external dependencies then you should build a Python egg. The .egg format was created to solve the issue you are dealing with. It is a self-contained release of your code with dependencies and meta-data. Here is some information on how create Python eggs.

Categories

Resources