2

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?

KCG
  • 23
  • 1
  • 6

2 Answers2

2

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.

Joe
  • 2,641
  • 5
  • 22
  • 43
1

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.

Mohd
  • 5,523
  • 7
  • 19
  • 30
  • Would this stop people being able to read the data inside the text files? – KCG Jul 08 '17 at 18:17
  • Not really, installer works like a zip file. Once you install, the files get extracted to the folder you specify. – Mohd Jul 08 '17 at 19:02
  • If you want to hide the content of the files, you can achieve that in many different ways. One of them is to have an encrypt/decrypt method in your script and only save encrypted data to the text file, and decrypt when reading – Mohd Jul 08 '17 at 19:07