0

I tried PyInstaller, but I was unable to include configuration and .txt files in the package.

cx_freeze throws an error during installation and py2exe is not supported for Python 3.6 and later.

Which Python-to-EXE library can I use for Python 3.7?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zid
  • 439
  • 1
  • 4
  • 18

1 Answers1

5

auto-py-to-exe supports Python 3.7.

The added data/txt files need to be read in the code like this:

open(sys._MEIPASS+ r'filename.txt').read()

It was taken from Stack Overflow question PyInstaller cannot add .txt files.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
frankegoesdown
  • 1,898
  • 1
  • 20
  • 38
  • It's using PyInstaller underneath? – Zid Jun 29 '19 at 14:12
  • Yep but you should install PyInstaller >= 3.4 version - It supports python 3.7 – frankegoesdown Jun 29 '19 at 14:16
  • @Zid https://github.com/brentvollebregt/auto-py-to-exe/blob/4e2d9a3f8532fd9fc483c379f8f20800a1eaf73f/setup.py requirements – frankegoesdown Jun 29 '19 at 14:16
  • I c. I installed PyInstaller with latest `pip`. With PyInstaller there are other folders created like `dist` etc. With auto-py-to-exe I didn't see those folders just 1 exe in output folder and a __pycache__in the script folder. – Zid Jun 29 '19 at 14:18
  • @Zid Auto-py-to-exe it's a wrapping on pyInstaller. After all operations you get only 1 `exe`-file. If you work with PyInstaller in `dist` folders you can see sources. But they not needed for launching exe-file – frankegoesdown Jun 29 '19 at 14:22
  • I see. Thanks for saving my time. I'm fighting these packages for last 1 hr. :D – Zid Jun 29 '19 at 14:23
  • Unfortunately I'm still not able to call the read the packaged file. I included a simple txt file. I'm trying to read it with `print(open('file.txt').read())` – Zid Jun 29 '19 at 14:31
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/195741/discussion-between-zid-and-frankegoesdown). – Zid Jun 29 '19 at 14:32