How to convert py to exe with custom icon using py2exe module ?
How to convert py to exe using py2exe module with a custom icon ?
Hii, here I am going to post the answer of the above question and for better understanding I would give some visual pics, for any other query please comment.
Step 1: First of all we need to make a "sample.py ". The sample I mean is your project or program written in Python idle.
Step 2: For better results make a folder of any name and put your sample.py file into that folder.
Step 3: Now copy the following statement in a new .py file.
Source code
#================================================================
from distutils.core import setup
import py2exe
setup( windows=['sample.py'])
setup(windows=[
{''script':'sample.py',
"icon_resources":[(1,"goicon.icon")]
}])
#================================================================
*Note :1. Here the sample.py would be your script name,
2. If you are willing to make the console appear you may change the windows to console by just writing console by replacing windows.
3. The 'goicon.icon' should be changed with your icon name.
Step 4: Name the file as setup.py.
Step 5: Now assure that both setup.py , sample.py and the icon are all in the same folder. As mine ...
Step 6: Now open cmd and open the drive where you kept your folder. Now go to the folder as I am doing.
Step 7: Now type as I do...
Step 8: After this you will see a lot of written stuff on the cmd. Don't worry it's all process.
Step 9: After completing the cmd process, close it.
Step 10: Go to the folder. Their you will see two folders 'dist' and 'build'.
Step 11: Now just copy your files required for the program to run. Copy it in your 'dist' folder. There you will see your sample.exe, this was your .py file converted into .exe.
Hence, you created your .exe executable file with your custom icon.
Hii, here I am going to post the answer of the above question and for better understanding I would give some visual pics, for any other query please comment.
Step 1: First of all we need to make a "sample.py ". The sample I mean is your project or program written in Python idle.
Step 2: For better results make a folder of any name and put your sample.py file into that folder.
Source code
#================================================================
from distutils.core import setup
import py2exe
setup( windows=['sample.py'])
setup(windows=[
{''script':'sample.py',
"icon_resources":[(1,"goicon.icon")]
}])
#================================================================
*Note :1. Here the sample.py would be your script name,
2. If you are willing to make the console appear you may change the windows to console by just writing console by replacing windows.
3. The 'goicon.icon' should be changed with your icon name.
Step 4: Name the file as setup.py.
Step 5: Now assure that both setup.py , sample.py and the icon are all in the same folder. As mine ...
Step 6: Now open cmd and open the drive where you kept your folder. Now go to the folder as I am doing.
Step 7: Now type as I do...
Step 8: After this you will see a lot of written stuff on the cmd. Don't worry it's all process.
Step 9: After completing the cmd process, close it.
Step 10: Go to the folder. Their you will see two folders 'dist' and 'build'.
Step 11: Now just copy your files required for the program to run. Copy it in your 'dist' folder. There you will see your sample.exe, this was your .py file converted into .exe.
Hence, you created your .exe executable file with your custom icon.
I liked this post
ReplyDelete