【发布时间】:2016-10-12 02:37:56
【问题描述】:
我正在尝试为 python 脚本“cnss_image_loader.py”生成一个 exe,该脚本在同一文件夹中导入其他 python 脚本(见下文),现在我尝试使用命令python setup.py py2exe(见输出如下)并遇到以下错误,不确定它们是否是真正的问题,但是在运行生成的 exe 时会引发如下所示的错误
问题:
1.不能用py2exe生成可执行文件吗?
2.谁能准确指出我缺少的内容并提供生成 exe 的指导?
3.有没有更好的方法来生成python可执行文件?
错误:-
C:\Dropbox\py2exe\dist>cnss_image_loader.exe
Traceback (most recent call last):
File "cnss_image_loader.py", line 9, in <module>
File "android_dl.pyc", line 2, in <module>
File "pip\__init__.pyc", line 14, in <module>
File "pip\utils\__init__.pyc", line 22, in <module>
File "pip\compat\__init__.pyc", line 26, in <module>
ImportError: No module named ipaddr
cnss_image_loader.py
from android_dl import *
from alpaca import *
setup.py
from distutils.core import setup
import py2exe
setup(console=['cnss_image_loader.py'])
python setup.py py2exe
The following modules appear to be missing
['Carbon', 'Carbon.Files', 'ElementC14N', 'OpenSSL.SSL', 'Pyrex.Distutils.build_ext', '_frozen_importlib', '_imp', '_manylinux', '_posixsubprocess', '_scproxy', '_sysconfigdata', 'backports.ssl_match_hostname', 'builtins', 'certifi', 'charade.universaldetector', 'chardet', 'chardet.universaldetector', 'configparser', 'datrie', 'genshi.core', 'html', 'html.entities', 'html.parser', 'http', 'http.client', 'http.cookies', 'importlib.machinery', 'importlib.util', 'ipaddr', 'ipaddress', 'java', 'lxml', 'lxml.etree', 'lzma', 'ndg.httpsclient.ssl_peer_verification', 'ndg.httpsclient.subj_alt_name', 'ordereddict', 'packages.six.moves', 'packages.ssl_match_hostname.CertificateError', 'packages.ssl_match_hostname.match_hostname', 'packages.urllib3.util.Timeout', 'packages.urllib3.util.parse_url', 'pip._vendor.six.moves.urllib', 'pyasn1.codec.der', 'pyasn1.type', 'queue', 'redis', 'reprlib', 'serial', 'serial.tools.list_ports', 'serializer.serialize', 'simplejson', 'sitecustomize', 'socks', 'tree
builders.getTreeBuilder', 'treewalkers.getTreeWalker', 'trie.Trie', 'urllib.error', 'urllib.parse', 'urllib.request', 'urllib3', 'urllib3.packages.backports.makefile', 'usercustomize', 'xmlrpc.client']
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.
Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.
OLEAUT32.dll - C:\WINDOWS\system32\OLEAUT32.dll
USER32.dll - C:\WINDOWS\system32\USER32.dll
IMM32.dll - C:\WINDOWS\system32\IMM32.dll
SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
ole32.dll - C:\WINDOWS\system32\ole32.dll
COMDLG32.dll - C:\WINDOWS\system32\COMDLG32.dll
COMCTL32.dll - C:\WINDOWS\system32\COMCTL32.dll
ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll
NETAPI32.dll - C:\WINDOWS\system32\NETAPI32.dll
WS2_32.dll - C:\WINDOWS\system32\WS2_32.dll
GDI32.dll - C:\WINDOWS\system32\GDI32.dll
VERSION.dll - C:\WINDOWS\system32\VERSION.dll
KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll
ntdll.dll - C:\WINDOWS\system32\ntdll.dll
【问题讨论】:
-
顺便说一句,如果python脚本不包含其他python脚本,则此方法有效