【发布时间】:2015-01-08 14:46:32
【问题描述】:
我正在尝试使用 Py2Exe 将我的 python 项目转换为 exe。值得注意的是,cx_freeze 抱怨同样的三个“缺少模块”,以及其他几十个模块。问题是,没有人告诉如何解决这个问题。
我在 MS Windows XP 32 位 (VirtualBox) 上构建。
C:\Documents and Settings\Jason\Desktop\redstring2>python setup.py py2exe
running py2exe
running build_py
creating build
creating build\lib
copying redstring.py -> build\lib
3 missing Modules
------------------
? readline imported from cmd, code, pdb
? win32api imported from platform
? win32con imported from platform
Building shared code archive 'dist\library.zip'.
Copy c:\windows\system32\python34.dll to dist
Copy C:\Python34\DLLs\select.pyd to dist\select.pyd
Copy C:\Python34\DLLs\_ssl.pyd to dist\_ssl.pyd
Copy C:\Python34\DLLs\_ctypes.pyd to dist\_ctypes.pyd
Copy C:\Python34\DLLs\_lzma.pyd to dist\_lzma.pyd
Copy C:\Python34\DLLs\_hashlib.pyd to dist\_hashlib.pyd
Copy C:\Python34\DLLs\pyexpat.pyd to dist\pyexpat.pyd
Copy C:\Python34\DLLs\_socket.pyd to dist\_socket.pyd
Copy C:\Python34\DLLs\_bz2.pyd to dist\_bz2.pyd
Copy C:\Python34\DLLs\unicodedata.pyd to dist\unicodedata.pyd
我的setup.py如下。
#!/usr/bin/python python
from setuptools import setup
import py2exe
setup(name="Redstring",
version="2.0",
description="REDundant STRING generator",
author="MousePaw Labs",
url="http://www.mousepawgames.com/",
author_email="info@mousepawgames.com",
data_files=[("", ["redstring.png", "redstring_interface.glade"])],
py_modules=["redstring"],
)
这是一个使用 GTK+ 3(内置于 Glade)的 Python 3.4 项目。它在 Ubuntu 和 python redstring.py 上运行得非常好,但我无法将它编译为 .exe。
到目前为止,我在redstring.py 和setup.py 中都尝试了import platform、from platform import win32api 等,以及通过安装文件中的py2exe 选项导入平台。
【问题讨论】:
-
项目是否在windows下运行?
-
肯定的。 Windows XP cmd 中的 python redstring.py 完全没有任何问题。
-
好吧,如果你的意思是使用 py2exe 选项 'include': 'platform',是的,虽然它没有抛出任何错误,但它也没有解决问题。
标签: python python-3.x gtk py2exe