The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Page 2 -
How to convert .py to .exe?
Page 2 - Discuss How to convert .py to .exe? in the Python Programming forum on Dev Shed. How to convert .py to .exe? Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 18th, 2003, 12:02 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 12
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Quote: Originally posted by netytan
There are two ways that i know of to do this, 1 you could us the -w flag from the command line, something like..
python setup.py py2exe -w
2, give your python program a .pyw extension (abc.py becomes abc.pyw)
Mark. |
1.What does "-w" do?Can it remove the command window?
2.you mean change all .py files to .pyw?and run the command like "python setup.pyw py2exe -w?
Thank you.
|

October 18th, 2003, 06:01 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Well, pyw files run without the console window, so if you have a Python GUI (or any other Python program) with .pyw extension it will run without the "command window".. you just write a normal setup.py file and point it at your pyw
The -w flag will do exactly the same thing as the method above and works exactly the same way as normal, all you need to do is add -w to the end of your command
Mark.
__________________
programming language development: www.netytan.com – Hula
|

October 19th, 2003, 12:48 AM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 12
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Thanks a lot.
I tried add a -w after my command.It worked,and removed the DOS windows.
|

October 30th, 2003, 01:59 PM
|
|
Junior Member
|
|
Join Date: Oct 2003
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I have a question :
When you add the '-w' flag, it means you want to run your script with pythonw.exe. I tried this for a simple script and nothing happens when I launch my program (and it works when I build a console app). Do I need to add something in my script to run this way ?
|

October 30th, 2003, 03:33 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
Running a console app with pythonw.exe wont show and console window because thats exactly what its designed to do, your program still runs as normal though! Which is great when you want to make programs which run in the background (out of sight)..
Mark.
|

November 1st, 2003, 04:16 AM
|
|
Junior Member
|
|
Join Date: Oct 2003
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hummm... Sounds interesting. In fact it gave me an idea, but I have a problem :
When I added the pickle module to my script, I got a warning message while compiling saying that some modules could not be found (readline, carbon...). Now my script works fine before I convert it to exe but it doesn't work anymore after I've done so... What can I do ?
|

November 1st, 2003, 11:43 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
mnot sure exactly what your doing but i see no reason why it doesn't work.. you could try using one of the 'Flags to include or exclude modules or packages' on Py2exe's homepage i.e.
Quote:
--includes or -i list
comma separated list of modules to include. Note that includes overrides excludes. |
looks promising, give that a go, if it doesnt work then let me know and i'll run a few tests myself!
Take care,
Mark.
|

November 5th, 2003, 03:32 PM
|
|
Junior Member
|
|
Join Date: Oct 2003
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
ALRIGHT ! I did that and it worked... but I wasn't expecting it to work  . Thanks !
|

November 5th, 2003, 04:45 PM
|
|
Junior Member
|
|
Join Date: Oct 2003
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Oh, I forgot... When I convert some script to exe, (leaving the console...), I get warning messages that I don't see when running my script on Python GUI (such as "Warning : integer exponentiation", and some others...) Can I remove those and if yes how ?
Thanks in advance.
|

November 5th, 2003, 06:06 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
Mmmmmm, i've never head of this before and i can't find any docs on the p2exe website about this.. since warnings are not errors you cant really use the try statment on it (or i don't think so). I'll look into turning warnings off for you though and let you know what i find!
Mark.
|

November 5th, 2003, 06:57 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
Ok, there are two ways too do this from what i can see.. the first is by using the command line option -W arg which i havn't quite figured out yet! and the second (and my prefered) way if to use the warnings module i.e. import warnings; warnings.filterwarnings('ignore')
Hope this helps,
Mark.
|

November 5th, 2003, 07:06 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Ok, i got the -W thing down - got a little comfused there for a second or two  - if your calling a Python program from the command line and you want to turn warnings off you can do something like this:
python -W ignore path/to/python/program
the ignore option can be changed to yeild different results depending. I know this wont help much with Py2exe but just incase anyone was interested.
Mark.
|

November 6th, 2003, 03:44 AM
|
|
Junior Member
|
|
Join Date: Oct 2003
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Great ! I tried the warnings module thing and it worked perfectly.
Many thanks !
|

January 3rd, 2010, 03:12 PM
|
|
Registered User
|
|
Join Date: Jan 2010
Posts: 1
Time spent in forums: 27 m 5 sec
Reputation Power: 0
|
|
|
Py2.exe to PY
I have a different problem. I converted all my code from py to exe and then my system failed and then I found out that the system I had been using for my backups also failed. The only thing I have available to me is the exe file. So my problem now is how to convert the exe file back to py in the hopes of getting my source code back. Anyone have any ideas?
|

June 18th, 2012, 01:12 AM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 1
Time spent in forums: 19 m 28 sec
Reputation Power: 0
|
|
|
I need help for my file , to be executable..Can anyone help me ?
<edited by Scorpions4ever>That file is a key-generator for certain Huawei routers. </edited>
Last edited by Scorpions4ever : June 18th, 2012 at 01:35 AM.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|