-1

Firt, let be honest: I know nothing about python. I have created python file all by googled.

I have run file successfully but when i want to pack it to exe file it wont run. I have used 'Auto PY to EXE'(one file option) to pack 3 file (gui.py, copyfile.py, list.txt) but when i run exe file it just open Gui.exe but cant run 'Action.py". I move Gui.exe to folder where i stored copyfile.py and list.txt it run fined.

What should i do to make it only one exe file to run. (I want to share it to other people without install python)

Here is how my python file work: Open gui.py -> hit button -> execute file copyfile.py
(copyfile.py will copy file base on a list in list.txt) (all files are in same folder)

And i also dont want cmd window to appear when it run.


I have work around other ways by create a folder contains gui.exe, copyfile.exe, list.txt. But it run really slow, and when i copy to other computer (not have python) it say action.exe cant run copy command.

link to my file: https://drive.google.com/file/d/1OZIaCtiiBBxHjuNqrG1J59vHo9OV--3h/view?usp=sharing

TongManh
  • 1
  • 1

1 Answers1

0
  1. Install pyinstaller. Command: pip install pyinstaller
  2. In your terminal or command prompt type this command:
    pyinstaller --onefile -w [name of your file]

The -w is to prevent the command prompt from showing up. Don't use it if you are getting input from the user through the console by input()

  1. pyinstaller would have created a few useless folders and files. The only folder you need is the "dist" folder. You can delete the rest.
  2. You can take the file inside the dist folder and put it in your main directory. You don't need the dist directory either now.

This is from TechWithTim's How to Convert any Python File to .EXE video here.

  1. OPTIONAL: You can watch his video from this timestamp to make your whole main directory a executable.
ArjunSahlot
  • 426
  • 5
  • 13
  • thanks for your help. It really prevent cmd window open but it just pack one gui.py to exe and when i copy all the folder to other PC and run gui.exe file it will run copyfile.py and because that PC doesnt have python so no result. – TongManh Sep 18 '20 at 05:58
  • The usual way to use a python file from another is via import. So in your gui.py, you'll have `import copyfile` then later you'd call `copyfile.main()` or whatever function in copyfile.py you want to run. –  Dec 25 '20 at 05:54