玩蛇网提供最新Python编程技术信息以及Python资源下载!

py2exe编译链接python代码报错ImportError

使用py2exe编译链接python代码的时候,没出现问题,但在运行编译生成后的exe文件是,会报错:ImportError: No module named BeautifulSoup
百度了好久,都没找到答案,希望会的朋友帮忙提醒下,tks~

Python:2.7
BeautifulSoup:3.2

详细代码如下所示:

BeautifulSoupStudy.py

__author__ = 'Flying'
# -*- coding: utf-8 -*-
from BeautifulSoup import *  #HTML、XML
if __name__ =="__main__":
    doc = [
        '
', '

This is paragraph one.', '

This is paragraph two.', '' ] # BeautifulSoup 接受一个字符串参数 soup = BeautifulSoup(''.join(doc)) print soup.prettify()

setup.py

from distutils.core import setup  
import py2exe  
import sys  
includes = ["encodings", "encodings.*"]    
sys.argv.append("py2exe")  
options = {"py2exe":   { "bundle_files": 1 }    
                }   

setup(options = options,  
      zipfile=None,
      console = [{"script":'BeautifulSoupStudy.py'}])

报错如下

Traceback (most recent call last):
  File "BeautifulSoupStudy.py", line 3, in 
ImportError: No module named BeautifulSoup

BeautifulSoup 是一个模块,你检查一下有没有安装,没有的话 pip install beautifulsoup

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd19917.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
修订日期:2017年05月23日 - 11时10分46秒 发布自玩蛇网

您现在的位置: 玩蛇网首页 > Python问题解答 > 正文内容
我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules