Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have just started learning python after learning some C++14 and have encountered a problem. I have used the correct version of py2exe to successfully compile python 2.7 scripts to standalone executables which also pause before the program closes so user can view output. I have also been able to create a python 3.3 bytecode executable using the corresponding version of py2exe, but it stubbornly refuses to pause before closing. I have used the correct syntax for python 3 to pause program where the following should work: x = input("press enter")
But the program still does not pause before closing after compiling to .pyc file.
Please help me to accomplish this task, I greatly appreciate all of your help. Sincerely, Adam.

What I have tried:

I have looked up, downloaded, and installed the correct version of py2exe for compiling python 3.3+. I have also made sure I used the correct syntax for python 3.3 but have had no success. I cannot conceive of what I may be doing wrong, and would be grateful for any assistance in this matter. Thank you.
Posted
Updated 26-Aug-16 23:53pm
Comments
Patrice T 27-Aug-16 0:00am    
Try to show related code.
Richard MacCutchan 27-Aug-16 3:48am    
You need to add some debug code to try and isolate what is happening. It is impossible for anyone else to guess what your program is doing.

1 solution

First check your code (If correct follow the below steps else post your code on your question)

From my experience:

I am currently using Python 3.5.2 and Py2exe is more suitable for Python 2 and but I found several difficulties since it doesn't have good support for Python -3 especially 3.5 versions. I can't downgrade my Python 3.5 to 2.7 for this simple stuff.

What I have done to solve the problem is: I have downloaded the Library called PyInstaller
which provides excellent support for both 2.x and 3.x versions of python.

I would suggest you to use the same for compiling python into binaries. You can compile standalone exe's for windows ,packages for MAC(I don't have mac book but I know Pyinstaller is capable of doing so) and also for linux.

Feel free to ask doubts

UPDATE:
1. To build binaries for Windows from Python script one must have installed PyWin32 in suitable architechture.

Python for Windows Extensions - Browse /pywin32/Build 220 at SourceForge.net[^]

select your appropriate Windows architecture and install it from the link given above.

2. Download Pyinstaller(Don't install it using PIP or easy_install etc.,) Download the compressed package and extract it to a folder of your choice You can extract it in any drive you want.

3. After extraction you will find Pyinstaller folder open it.

4. consider example.py is the name of the script you ant to build an executable.

5. Open the Pyinstaller folder and paste example.py there(there are other ways to do without pasting it here but this is easiest one).

6. Press SHIFT and hit right click and your mouse(you should not release the shift button when right clicking the mouse) you will find open command window option there.

7. Select it command prompt will be opened.

If you have set Python to your environment variables follow 8(a) else follow 8(b)

8(a). Type this command

Pyinstaller.py --onefile example.py

example.py is the name of your script.

8(b). Type this command

Path of python Pinstaller.py --onefile example.py

Replace path of python to your python path

example shown for Python 3.5.2:
C:\Users\User\AppData\Local\Programs\Python\Python35-32\python.exe Pinstaller.py --onefile example.py

You will find exe placed in dist folder.

Update 2:
If you are using two versions of python follow the below steps.

1. Make sure you have installed correct version of PyWin32 for both 2.7 and 3.5.2 version.

2. Extract the Pyinstaller folder(I think you have extracted already)

3. Environment variable may have set to Python 2.7 so better you follow step 1 to 7 and follow 8(b) i.e use your Python3 location to build the executable


If you still face any problems feel free to ask me.
 
Share this answer
 
v3
Comments
Member 12419675 27-Aug-16 22:07pm    
Hello VISWESWARAN1998, I've had some success but have encountered another problem. I was able to download, install, and attempt to use pyinstaller, however; the dist folder was empty even after using the --onefile command although all expected files were in the build folder. I do not know how to solve this problem. I greatly appreciate your help, sincerely, Adam.
[no name] 28-Aug-16 2:05am    
Updated the solution for you kindly have a look at it and if you face any problems still feel free to drop a comment here.
Member 12419675 28-Aug-16 14:19pm    
Hello, I can't tell you how much I appreciate all of your patient help. I have set python to my environment variables but receive the following error when attempting 8(a): Import Error: No module named 'pywint ypes'

This is not a typo but is exact error message received. I have looked up and tried many things as well as trial and error but nothing has worked thus far. Thank you for helping me, and much respect from a fellow programmer, sincerel, Adam.
[no name] 28-Aug-16 21:31pm    
I am quiet sure you should have installed wrong version of PyWin32 give me your system archicture and python version let me pick the right one for you.
Member 12419675 28-Aug-16 21:49pm    
I'm on a 64 bit Dell, using windows10, and python 3.5.2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900