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.
Related
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.
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
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 4 years ago.
Improve this question
I am making a program that will call python. I would like to add python in my project so users don't have to download python in order to use it, also it will be better to use the python that my program has so users don't have to download any dependency.
My program it's going to be writing in C++ (but can be any language) and I guess I have to call the python that is in the same path of my project?
Let's say that the system where the user is running already has python and he/she calls 'pip' i want the program to call pip provided by the python give it by my program and install it in the program directory instead of the system's python?
It's that possible? If it is how can I do it?
Real examples:
There are programs that offer a terminal where you can execute python to do things in the program like:
Maya by Autodesk
Nuke by The foundry
Houdini by Side Effects
Note: It has to be Cross-platform solution
There are programs that "freeze" your python program including Python itself, for example Pyinstaller (http://www.pyinstaller.org/)
It won't help with the requirement in the third paragraph though, for that you'd have to include Python itself as part of the complete download, which seems unnecessary.
In order to run python code, the runtime is sufficient. Under Windows, you can use py2exe to pack your program code together with the python runtime and all recessary dependencies. But pip cannot be used and it makes no sense, as you don't want to develop, but only use the python part.
To distribute the complete python installation, like Panda3D does, you'll have to include it in the chosen installer software.
You can use py2exe to turn you python program into an executable. You do not need to keep python in the executable.
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 need to develop a GUI desktop application that takes input from the user, does some calculations, and then runs a bunch of queries which should be exported into a csv, xls or txt file. I want to create an installation package which the user can install without installing any other applications (used for front end) and other database (other than MS Access). My questions are
If I use python for my front-end/GUI, can I create an installation package? I understand that we can create and .exe file from the .py file. I want the dB to be get copied in the right folder (path referenced in my program) on the end-user's computer when the user installs the package.
MS Access (2010) on my computer (Windos 7 OS) is 32-bit and I'm having trouble using it with 64-bit python (version 3.5.1) and pyodbc(version 3.0.10). Can I use any alternate dB (sqlite?) that the user doesn't have to install to run the application and I don't have to worry about getting the dB in the right folder on the end-users computer. My dB is very small (few tables with about 1000 rows each).
Thanks much!
Looks like you can do both - pyinstaller seems to support sqlite3, the python library for working with sqlite which seems like a great fit for your use case:
https://docs.python.org/3/library/sqlite3.html
https://pypi.python.org/pypi/PyInstaller/3.0
About exporting - you can write code for that using python, depends on the exact output you are looking for.
Here's an example of using sqlite tools for basic export:
Export from sqlite to csv using shell script
Hope this helps :)
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 am trying to make a program with python that downloads a large .scd file, unpacks it, and then installs it. It is not at all difficult for me to download it or install it, (which is pretty much just using urllib and moving a few files around) but unpacking it seems to be a problem. After a couple hours of Googling I can't seem to find any modules for Python capable of opening .scd archives. One idea is to try to convert is to a .zip file with Python, replace the .scd with that, and the just use zipfile.extractall(). I am fine with this if someone can tell me how to do the conversion. The conversion/extraction MUST be automated.
EDIT: It is OK with me if a use 3rd party software, but I still would like the following things: the process must be totally automated, (the user does not have to hit an extract button or anything along those lines) the 3rd party software must have a license that allows me to use it as part of my Python program, (and distribute it as part of my program's package to the general public) and the software is compatible with Windows.
OK, after numerous hours on google I found out that .scd's are basically .zip's with a 0% compression rate. Try using the built in zipfile module on your file as though it were a .zip.