-6

I had built a simple program with minimalistic code Code and converted it into a .exe file using command prompt after which it refused to boot after I opened the .exe file in Visual Studio after which it prompted this

enter image description here

and allowed it to fix some errors then I saw some changes in the program, But then when I tried to open it, This showed up

enter image description here

and so is there a way to make the program boot and run and do I need additional code to make the program run?

  • 2
    How, exactly, did you "fix some errors" in a binary file? – Tim Roberts Mar 20 '21 at 04:37
  • 1
    HI Mav, take a look at [this thread](https://stackoverflow.com/questions/5458048/how-can-i-make-a-python-script-standalone-executable-to-run-without-any-dependen), it seems to answer your question. – Shir Mar 20 '21 at 04:43
  • 1
    @Tim Roberts Well Visual Studio prompted to remove some line terminators –  Mar 20 '21 at 04:44
  • 1
    .exe files consist of a series of loader tables that are understood by the operating system. There is a table of contents at the beginning that points to each of the tables. If you insert or delete characters, the table of contents doesn't match and the file is garbage. No, if you change the Python code, you have to regenerate the exe. – Tim Roberts Mar 20 '21 at 04:45
  • 1
    @Tim Roberts Thank you for the info as I did not know it before, But I did not change the Python code and the code was all encoded in some other symbols and after I allowed Visual Studio to fix the errors I just saved it after which my problem raised Where else earlier the program simply refused to open –  Mar 20 '21 at 04:51
  • 1
    Right. **Don't do that.** It's as easy as that. There is nothing in an executable file that you can manipulate in VSCode. You'll need to rebulid it now. – Tim Roberts Mar 20 '21 at 04:53
  • @Tim Robert As I have already said it before after I created the .exe file using pyinstaller and the command prompt it does create the directory "Dist" and the aforementioned file does exist but when I try to open it, it shows unresponsive activity –  Mar 20 '21 at 05:27
  • Did you try to run the .exe immediately after you created it, before you destroyed it in the editor? – Tim Roberts Mar 20 '21 at 05:36
  • @Tim Roberts Yes I did but it was unresponsive and failed to boot up –  Mar 20 '21 at 05:39
  • What is the app? If it is minimal, just add the code to your question. – Tim Roberts Mar 20 '21 at 05:40
  • @TimRoberts I have been careless and overlooked my matter and it turns out that the program is working perfectly fine Sorry for bothering you –  Mar 21 '21 at 13:52
  • Well, because you are using windows, you should technically use CRLF line terminators. – Lakshaya U. Apr 19 '21 at 05:22

1 Answers1

1

Easy-peasy solution. Do pip install pyinstaller and then from run pyinstaller --onefile filename.py

Lakshaya U.
  • 1,089
  • 1
  • 5
  • 21
  • I have already done that My problem arises only after that part I have converted it into a .exe file but the problem is it is not opening up and even after some error fixing if it does show some response it says "This app can't run on your PC" –  Mar 20 '21 at 05:24
  • can you share your code? or maybe you did not install the correct architecture of python? Also the line terminators in python are usually CRLF so maybe that's causing the issue. – Lakshaya U. Mar 20 '21 at 07:36