首页 > Py2exe:ImportError: No module named BeautifulSoup

Py2exe:ImportError: No module named BeautifulSoup

使用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 = [
        'Page title',
        '

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

【热门文章】
【热门文章】