[英]BeautifulSoup import error in Python3.3
只用了一周就開始學習 Python。 我已經使用 easy_install 安裝了 BeautifulSoup4。 安裝似乎沒問題,因為在 Python shell 中沒有錯誤並使用 from bs4 import BeautifulSoup。
嘗試在我從 win7 上的 cmd 控制台調用的腳本中使用“from bs4 import BeautifulSoup”時出現錯誤“python C:\\Users\\Ryan\\Desktop\\precipitation.py”
從 bs4 導入 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
嘗試至少安裝 python3.5+。 Python3.3 於 2013 年發布(7 年前!)。
看來您是在 Windows 上運行的。 在這種情況下,您可能只需下載 anaconda,這將使您的生活更輕松: https : //anaconda.org/anaconda/beautifulsoup4 。
參考:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.