Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
188 views
in Technique[技术] by (71.8m points)

python - Py2Exe "Missing Modules"

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 SettingsJasonDesktop
edstring2>python setup.py py2exe
running py2exe
running build_py
creating build
creating buildlib
copying redstring.py -> buildlib

  3 missing Modules
  ------------------
? readline                            imported from cmd, code, pdb
? win32api                            imported from platform
? win32con                            imported from platform
Building shared code archive 'distlibrary.zip'.
Copy c:windowssystem32python34.dll to dist
Copy C:Python34DLLsselect.pyd to distselect.pyd
Copy C:Python34DLLs\_ssl.pyd to dist\_ssl.pyd
Copy C:Python34DLLs\_ctypes.pyd to dist\_ctypes.pyd
Copy C:Python34DLLs\_lzma.pyd to dist\_lzma.pyd
Copy C:Python34DLLs\_hashlib.pyd to dist\_hashlib.pyd
Copy C:Python34DLLspyexpat.pyd to distpyexpat.pyd
Copy C:Python34DLLs\_socket.pyd to dist\_socket.pyd
Copy C:Python34DLLs\_bz2.pyd to dist\_bz2.pyd
Copy C:Python34DLLsunicodedata.pyd to distunicodedata.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="[email protected]",
    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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...