convert python programme to windows executable

2024/9/20 9:45:29

i m trying to create windows executable from python program which has GUI . i m using following script

from distutils.core import setup
import py2exesetup(console=['gui.py']) 

it gives following error

Warning (from warnings module):File "C:\Python27\lib\distutils\dist.py", line 267warnings.warn(msg)
UserWarning: Unknown distribution option: 'console'Traceback (most recent call last):File "E:\my python\py2exe.py", line 3, in <module>import py2exeFile "E:\my python\py2exe.py", line 5, in <module>setup(console=['ASUP_finalDone1.py'])File "C:\Python27\lib\distutils\core.py", line 140, in setupraise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: py2exe.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]or: py2exe.py --help [cmd1 cmd2 ...]or: py2exe.py --help-commandsor: py2exe.py cmd --helperror: no commands supplied

i can't understand why to need for supplying command as it is GUI based application but it worked fine first time and then it gives above error. please help..........

Answer

The problem is that you are compiling this script from the Python IDLE. This is not how it is done with py2exe. If you have used Disutils before, you might have seen this:

python setup.py install.

And same is the case of py2exe, you run it from the command line and not the IDLE. So open up cmd and then issue the command:

python setup.py py2exe

Here setup.py is your script file.

This is better explained in the tutorial.

https://en.xdnf.cn/q/72512.html

Related Q&A

Must explicitly set engine if not passing in buffer or path for io in Panda

When running the following Python Panda code:xl = pd.ExcelFile(dataFileUrl)sheets = xl.sheet_namesdata = xl.parse(sheets[0])colheaders = list(data)I receive the ValueError:Must ex…

How to access the keys or values of Python GDB Value

I have a struct in GDB and want to run a script which examines this struct. In Python GDB you can easily access the struct via(gdb) python mystruct = gdb.parse_and_eval("mystruct")Now I got t…

How can I fire a Traits static event notification on a List?

I am working through the traits presentation from PyCon 2010. At about 2:30:45 the presenter starts covering trait event notifications, which allow (among other things) the ability to automatically ca…

Calculate moving average in numpy array with NaNs

I am trying to calculate the moving average in a large numpy array that contains NaNs. Currently I am using:import numpy as npdef moving_average(a,n=5):ret = np.cumsum(a,dtype=float)ret[n:] = ret[n:]-r…

Python: numpy.insert NaN value

Im trying to insert NaN values to specific indices of a numpy array. I keep getting this error:TypeError: Cannot cast array data from dtype(float64) to dtype(int64) according to the rule safeWhen tryin…

Identify external workbook links using openpyxl

I am trying to identify all cells that contain external workbook references, using openpyxl in Python 3.4. But I am failing. My first try consisted of:def find_external_value(cell): # identifies an e…

3D-Stacked 2D histograms

I have a bunch of 2D histograms (square 2D numpy arrays) that I want to stack in 3D like so:(Image from: Cardenas, Alfredo E., et al. "Unassisted transport of N-acetyl-L-tryptophanamide through me…

Python and mySQLdb error: OperationalError: (1054, Unknown column in where clause)

Hey all, Im getting an error OperationalError: (1054, "Unknown column XX in where clause")Where XX is the value of CLASS in the following codeconn = MySQLdb.connect(host = "localhost&quo…

Best Python GIS library? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, argum…

Build a class with an attribute in one line

How do I write a one-liner for the following? class MyClass(): content = {} obj = MyClass()