写了一个python程序(python2.7),用py2exe打包成一个native exe,结果老是报错
Traceback (most recent call last): File "p4_ticket_auth_jenkins.py", line 7, in <module> File "zipextimporter.pyc", line 82, in load_module File "jenkins\__init__.pyc", line 54, in <module> File "six.pyc", line 199, in load_module File "six.pyc", line 113, in _resolve File "six.pyc", line 80, in _import_module ImportError: No module named httplib
乍一看,貌似是py2exe打包时没有把httplib打包进去。
File "p4_ticket_auth_jenkins.py", line 7是import jenkins,看来是jenkins的lib导入出的问题。于是把python程序的逻辑部分删掉
import sys import argparse import logging import jenkins import xml.etree.ElementTree as ET import time import os from subprocess import Popen, PIPE, STDOUT import subprocess import commands import socket import datetime def main(): print("asdf") if __name__=="__main__": main()再用打包,运行打包后的exe,报错缺httplib。在python源码中import httplib,还报错缺urllib。import urllib,搞定
import sys import argparse import logging import jenkins import xml.etree.ElementTree as ET import time import os from subprocess import Popen, PIPE, STDOUT import subprocess import commands import socket import datetime import httplib import urllib2 def main(): print("asdf") if __name__=="__main__": main()
from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = {'py2exe': {'bundle_files': 1, 'compressed': True}}, console = [{'script': "test.py"}], zipfile = None, )
setup.py py2exe
py2exe error: "ImportError: No module named httplib"
原文地址:http://blog.csdn.net/ybdesire/article/details/45560733