Shama
Shama

Reputation: 23

py2exe term not recognized

I'm trying to make a .exe with py2exe running python 2.7.13

I used EXACTLY the files in the tutorial, hello.py, setup.py

next --> python setup.py py2exe

The "hello.exe" is in the dist folder, A-OK. I try to run it from PowerShell, C:\users\me\python\dist> hello.exe and I get this error.

The term 'hello.exe' is not recognized as the name of a cmdlet, funtion,
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:10
+ hello.exe <<<<

         + CategoryInfo          : ObjectNotFound: (hello.exe:String) [], CommandNotFoundException
         + FullyQualifiedErrorId : CommandNotFoundException

Suggestion [3,General]: The command hello.exe was not found, but does exist
in the current location. Windows Powershell does not load commands from the
current location by default. If you trust this command, instead type
".\hello.exe". See "get-help about_Command_Precedence" for more details.

It does run if I type ".\hello.exe" into powershell. It does not run when I double-click on the executable.

Am I doing something wrong? Do I need another .dll file?

EDIT: The nice people of stackoverflow have spoken. I was being slow(quite literally). Everything worked fine. Thank you all.

Upvotes: 0

Views: 589

Answers (1)

Gerad Bottorff
Gerad Bottorff

Reputation: 65

It's been a long time since I used py2exe but when I used it after the main functionality of the program was complete it would simply exit. This means that once your program is finished executing, which I think for the file names would be just printing hello world or something, it will exit.

Opening a window printing to it and exiting is actually really quick and might be too quick to draw to the screen. I'll bet that is what is happening for you. If you add a statement like time.sleep(30) or raw_input("Press any key to exit...") I'll bet that it would 'run' properly and you'd see an actual program.

I would also suggest becoming accustom to running things from the command line as you get the output of the results, with programs like this, and you can usually tell if something went wrong.

Upvotes: 1

Related Questions