Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python 3.3中将.py文件编译为.exe_Python_Python 3.x_Py2exe - Fatal编程技术网

在Python 3.3中将.py文件编译为.exe

在Python 3.3中将.py文件编译为.exe,python,python-3.x,py2exe,Python,Python 3.x,Py2exe,我想不出能不能让py2exe正常工作 我希望将此test.py转换为test.exe: test.py代码: print("Hello World!") 编辑: 显然,我使用了Python2.x方法。当我改用3.3命令时: py -3.3 -m py2exe.build_exe test.py 我得到了新的错误: D:\program\python\lib\distutils\dist.py:257: UserWarning: Unknown distribution o pt

我想不出能不能让py2exe正常工作

我希望将此test.py转换为test.exe:

test.py代码:

print("Hello World!")
编辑:

显然,我使用了Python2.x方法。当我改用3.3命令时:

 py -3.3 -m py2exe.build_exe test.py
我得到了新的错误:

 D:\program\python\lib\distutils\dist.py:257: UserWarning: Unknown     distribution o
 ption: 'console'
 warnings.warn(msg)
 invalid command name 'test.py'
感觉就像我经常撞到墙一样。对这个新错误有什么见解吗

帖子的旧部分:

我使用以下代码创建了setup.py:

from distutils.core import setup
import py2exe

setup(console=['test.py'])
我用pip安装了py2exe(版本0.9.2.2)。当我移动到包含setup.py和test.py的文件夹并运行命令时:

python setup.py py2exe
我遇到了错误:

 D:\program\python\lib\distutils\dist.py:257: UserWarning: Unknown distribution o
 ption: 'console'
   warnings.warn(msg)
 usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
    or: setup.py --help [cmd1 cmd2 ...]
    or: setup.py --help-commands
    or: setup.py cmd --help

error: invalid command 'py2exe'

python文档不鼓励使用
distutils
模块。而是使用
setuptools
,如下所示

from setuptools import setup
import py2exe

setup(scripts=['test.py'])

但是,在Python3下,您不能使用
py2exe
有关详细信息,请参见。

对于Python2安装程序执行,请使用以下命令:
py-3.4-m py2exe.build_exe test.py
谢谢Malik。我查了一下,你是对的;然而,它仍然不起作用。有什么不知道为什么的线索吗?试过了,但没用。据我所知,这只是python2.x解决问题方法的扩展?我正在运行python3.3。