py2exe error: "ImportError: No module named httplib"

写了一个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()

附上setup.py的代码:

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可以把python代码(test.py)打包成native exe(不需要任何其他库的支持就能直接在windows上运行)。一条命令实现打包:

setup.py py2exe
时间: 2024-10-09 00:49:33

py2exe error: "ImportError: No module named httplib"的相关文章

/usr/bin/python3: Error while finding spec for &#39;virtualenvwrapper.hook_loader&#39; (&lt;class &#39;ImportError&#39;&gt;: No module named &#39;virtualenvwrapper&#39;)

解决方案 sudo apt-get install python3-pip sudo pip3 install virtualenv virtualenvwrapper source .bashrc /usr/bin/python3: Error while finding spec for 'virtualenvwrapper.hook_loader' (<class 'ImportError'>: No module named 'virtualenvwrapper') 原文地址:http

ubuntu上跑python连接pg,报错 ImportError: No module named psycopg2

ubuntu上跑python连接pg,报错  ImportError: No module named psycopg2 [email protected]:~# python /home/zxw/PGWriterTest_m.py Traceback (most recent call last): File "/home/zxw/PGWriterTest_m.py", line 4, in <module> import psycopg2 ImportError: No

ImportError: No module named python_util.util

从师兄那里拷贝了一个python文件,运行报错ImportError: No module named python_util.util,python小白上网搜,并没有搜到有价值的答案...经过摸索,最后解决. 其实这就是缺少python_util.util,到这个网址https://pypi.python.org/pypi/python-util/2.0.0#downloads下载,如下图所示,选第一个就可以,下载之后解压缩,里面有一个setup.py 输入命令python setup.py,

Centos 7 python 编译报错 ImportError: No module named six 解决办法

本地编译Open vSwitch时报错 Traceback (most recent call last):   File "./ovsdb/ovsdb-idlc.in", line 8, in <module>     import ovs.json   File "/root/rpmbuild/BUILD/openvswitch-2.6.0/python/ovs/json.py", line 21, in <module>     imp

[Airflow] ImportError: No module named lockfile.pidlockfile

When setting up a clean install of airflow on ubuntu 14.04, I ran into the following error: [email protected]:~$ airflow [2016-07-19 15:37:41,839] {__init__.py:36} INFO - Using executor SequentialExecutor [2016-07-19 15:37:41,912] {driver.py:120} INF

安装HTMLTestRunner提示 ImportError: No module named &#39;StringIO&#39;

python3中用HTMLTestRunner.py报ImportError: No module named 'StringIO'的解决方法:  Import HTMLTestRunner 1.原因是官网的是python2语法写的,看官手动把官网的HTMLTestRunner.py改成python3的语法: 参考:http://bbs.chinaunix.net/thread-4154743-1-1.html 下载地址:http://tungwaiyip.info/software/HTMLT

ImportError: No module named psutil的解决

系统版本: cat /etc/redhat-release CentOS release 6.9 (Final) 跑python脚本的时候报错ImportError: No module named psutil,于是想要用pip来安装,但是发现pip也没装: #  pip install psutil -bash: pip: command not found 先来安装pip吧: wget "https://pypi.python.org/packages/source/p/pip/pip-1

linux7中python ImportError: No module named pymc 处理

linux7中python ImportError: No module named pymc 处理方法 系统环境 #cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) #python -V Python 2.7.5 pip安装pymc报错#报错内容如下:error: lapack/double/dpotrs.f: No such file or directory 解决方法(1)最简单的方式--pip #从上面报错内容可知,

ImportError: No module named caffe.proto解决办法

原文   https://blog.csdn.net/lanyuelvyun/article/details/73628152 在用自己的数据训练基于caffe的SSD模型的时候,我们需要将图片数据转换成lmdb格式,用到的脚本文件是SSD源码里面提供的create_data.sh(具体位置在$CAFFE_ROOT/data/VOC0712/create_data.sh),将它copy一份,取一个自己的名字,比如creat_scenetext_data.sh,然后根据自己的实际情况修改里面的路径