Py2Exe“丢失模块” [英] Py2Exe "Missing Modules"

查看:488
本文介绍了Py2Exe“丢失模块”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Py2Exe将我的python项目转换成一个exe文件。值得注意的是,cx_freeze抱怨同样的三个缺失模块以及其他几十个模块。问题是,没有人告诉我如何解决这个问题。



我在MS Windows XP 32位(VirtualBox)上构建。

  C:\Documents and Settings\Jason\Desktop\redstring2> python setup.py py2exe 
运行py2exe
正在运行build_py
创建构建
创建build\lib
复制redstring.py - > build \lib

3缺少模块
------------------
?从cmd导入的readline,代码,pdb
? win32api从平台
导入? win32con从平台导入
构建共享代码档案dist\library.zip。
将c:\windows\system32\python34.dll复制到dist
复制C:\Python34\DLLs\select.pyd到dist\select.pyd
复制C:\Python34\DLLs\_ssl.pyd到dist\_ssl.pyd
将C:\Python34\DLLs\_ctypes.pyd复制到dist\_ctypes.pyd
复制C:\Python34\DLLs\_lzma.pyd to dist\_lzma.pyd
将C:\Python34\DLLs\_hashlib.pyd复制到dist\_hashlib.pyd
复制C:\Python34\DLLs\pyexpat.pyd到dist\pyexpat.pyd
将C:\Python34\DLLs\_socket.pyd复制到dist\_socket.pyd
复制C:\Python34\DLLs\_bz2.pyd到dist\_bz2.pyd
将C:\Python34\DLLs\unicodedata.pyd复制到dist\unicodedata.pyd

我的 setup.py 如下。

 #!/ usr / bin / python python 
$ b $ from setuptools import setup
import py2exe

setup(name =Redstring,
ve rsion =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。



到目前为止,我尝试了 import platform from platform import win32api ,以及 redstring.py setup.py ,以及通过设置文件中的py2exe选项导入平台。 >解决方案

win32api和win32con是Mark Hammond的Python Windows扩展(aka pywin32)的一部分。 readline是一个与控制台交互的代码(如果有的话)使用的模块。



readline和pywin32都是可选的模块/软件包,并非绝对必需的,但会当存在时使用。



总而言之 - py2exe注意到这些模块/软件包被一些代码引用,这些代码将被包含到您的exe文件中(它甚至提到了模块引用这些mod / packages:cmd,code,pdb,platform)。
我希望你已经测试了你的脚本 - 在'非编译'的形式下,如果它能正常工作,你可以放心地忽略这些消息:它们只是警告。



没有构建可执行文件的原因是setup()调用中缺少'console = ['redstring']'或'windows = [redstring]''行。


I'm trying to convert my python project into an exe using Py2Exe. It is worth noting that cx_freeze complains about the same three "missing modules", along with several dozen others. The problem is, no one anywhere tells how to resolve this.

I'm building on MS Windows XP 32-bit (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

My setup.py is as follows.

#!/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"],
    )

This is a Python 3.4 project using GTK+ 3 (built in Glade). It runs just peachy on Ubuntu, and from python redstring.py, but I can't get the thing to compile down to an .exe.

So far I tried import platform, from platform import win32api, and all the like in both redstring.py and setup.py, along with importing platform via py2exe options in the setup file.

解决方案

win32api and win32con are part of Mark Hammond's Python Windows extensions (aka pywin32). readline is a module that is used (if present) by some code interacting with the console.

Both readline and pywin32 are optional modules/packages that are not abolutely required but will be used when present.

All in all - py2exe notices that these modules/packages are referenced by some code which will be included into your exe (it even mentions the modules that reference these mod/packages: cmd, code, pdb, platform). I hope you have tested your script - in the 'non-compiled' form, if it works correctly than you can safely ignore these messages: they are only warnings.

The reason that no executable is built is that the line 'console=["redstring"]' or 'windows=["redstring"]' is missing in the setup() call.

这篇关于Py2Exe“丢失模块”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆