Python3.3中的BeautifulSoup导入错误

时间:2013-06-20 05:47:51

标签: python windows beautifulsoup

只有一周的Python。我已经使用easy_install安装了BeautifulSoup4。安装似乎没问题,因为在Python shell中没有错误并且使用bs4导入BeautifulSoup。

在我从wind上的cmd控制台调用的脚本中尝试使用“from bs4 import BeautifulSoup”时出现错误“python C:\ Users \ Ryan \ Desktop \ precipitation.py”

  
    
      

来自bs4 import BeautifulSoup

    
  
#precipitation.py:

import urllib.request
import re
from bs4 import BeautifulSoup


#htmlfile = urllib.request.urlopen("http://www.wunderground.com/history/airport/KYIP/2013/6/16/DailyHistory.html6")
#htmltext = htmlfile.read()
#regex = b'<td class="indent"><span>Precipitation</span></td>\n<td><span class="nobr"><span class="b">(.+?)</span>''
#pattern = re.compile(regex)

print('Who made the Soup?!')

运行脚本时出错: python C:\ Users \ Ryan \ Desktop \ precipitation.py

Traceback (most recent call last):
File "C:\Users\Ryan\Desktop\precipitation.py", line 3, in
    from bs4 import BeautifulSoup
File "C:\Users\Ryan\Desktop\precipitation.py", line 1, in <module>
    from bs4 import BeautifulSoup
ImportError: cannot import name BeautifulSoup

1 个答案:

答案 0 :(得分:0)

尝试至少安装python3.5 +。 Python3.3于2013年发布(7年前!)。

似乎您正在Windows上运行。在这种情况下,您可以下载anaconda:https://anaconda.org/anaconda/beautifulsoup4

参考: