0

enter image description here

I recently made a chatbot using Python and Tkinter (and Pycharm). Now my bot runs successfully in a GUI made by me but I am intending to convert it into a .exe file to share it with my friends. Here are my codes of different scripts:

This was the error which came when I ran it on console: PS C:\Users\User\output\main> main.exe main.exe : The term 'main.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + main.exe + ~~~~~~~~ + CategoryInfo : ObjectNotFound: (main.exe:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Hrishi
  • 41
  • 9
  • 1
    what exactly failed? did you get any error messages in the console when running the `.exe`. I suggest you either use logging to determine where is the issue or remove parts of code and try compiling again and again, you have to provide a [mre] not three files – Matiiss Aug 13 '21 at 13:45
  • No sir. No error messages in the console. Works perfectly fine in the console. Only the problem arises while converting to exe using pyinstaller and auto py to exe – Hrishi Aug 13 '21 at 13:46
  • then why are you asking a question if everything is working fine? – Matiiss Aug 13 '21 at 13:47
  • I cant convert it to exe – Hrishi Aug 13 '21 at 13:48
  • what does _I can't convert to `.exe`_ mean?, also don't write so many comments, you can easily edit them – Matiiss Aug 13 '21 at 13:49
  • By console, I meant the python IDE. It works in the python IDE. While converting to .exe file using Pyinstaller, it says "Failed to execute Script main" – Hrishi Aug 13 '21 at 13:49
  • 1
    ok, and what error do you get when running the .exe? (run it with console or use `logging`) – Matiiss Aug 13 '21 at 13:50
  • Yeah I have added a picture of the error above. – Hrishi Aug 13 '21 at 13:52
  • that is not the error, we need the error traceback (run .exe with console and capture error from there or use `logging` to know which part failed) – Matiiss Aug 13 '21 at 13:59
  • Oh Im new to Python so dont exactly know what it means. Ill fig out and do as per – Hrishi Aug 13 '21 at 14:01
  • 1
    you know how when you run your code using IDE sometimes you may get an error and it says sth like: `Traceback (most recent call last):` (followed by what failed)? well you need to provide such error from when running the .exe (don't use no-console and see what the console says why it failed or use [`logging`](https://docs.python.org/3/howto/logging.html)) – Matiiss Aug 13 '21 at 14:05
  • PS C:\Users\User\output\main> main.exe main.exe : The term 'main.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + main.exe + ~~~~~~~~ + CategoryInfo : ObjectNotFound: (main.exe:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException – Hrishi Aug 13 '21 at 14:12
  • Is this the required info you were expecting? – Hrishi Aug 13 '21 at 14:13
  • possibly, but please add it to the question (using [edit]) so that it is properly formatted (therefore readable) also why do you have it inside the Scripts folder? related to that: https://www.reddit.com/r/Python/comments/6zxadq/what_is_the_cpython27scripts_folder_for/ – Matiiss Aug 13 '21 at 14:13
  • Initially it was in a separate folder, but it didnt work, so thats when some youtuber was explicitely mentioning to move it into scripts. SO that why. Yes I will edit – Hrishi Aug 13 '21 at 14:18

1 Answers1

1

You might be looking for Pyinstaller.

Pyinstaller is used to convert Python (.py) script to a Standalone Application (.exe)


Usage:

  • Open the Terminal and go the location of the project with the main python script.
  • Use the command pyinstaller <scriptname.py>
    • There are few attributes like:
      • --icon=<icon.ico> : To set the icon of the Application.
      • --onefile : To have your app as ONE .exe file.

Dhruv Anand
  • 103
  • 2
  • 10
  • the same thing as the other answer. `auto-py-to-exe` uses `pyinstaller` already, the issue is not with that (at least very unlikely) – Matiiss Aug 13 '21 at 14:23