1
的Python 3.4.3(64位),Windows 7的 我BS4 /請求被罰款運行,那麼我把所有這些東西從我的程序bs1.py:BeautifulSoup錯誤的Python 3.4.3
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\myprograms\bs1.py", line 1, in <module>
import requests, bs4
File "C:\Python34\lib\site-packages\requests\__init__.py", line 58, in <module>
from . import utils
File "C:\Python34\lib\site-packages\requests\utils.py", line 12, in <module>
import cgi
File "C:\Python34\lib\cgi.py", line 42, in <module>
import html
File "C:\Python34\myprograms\html.py", line 11, in <module>
import bs4
File "C:\Python34\lib\site-packages\bs4\__init__.py", line 29, in <module>
from .builder import builder_registry
File "C:\Python34\lib\site-packages\bs4\builder\__init__.py", line 4, in <module>
from bs4.element import (
File "C:\Python34\lib\site-packages\bs4\element.py", line 5, in <module>
from bs4.dammit import EntitySubstitution
File "C:\Python34\lib\site-packages\bs4\dammit.py", line 11, in <module>
from html.entities import codepoint2name
ImportError: No module named 'html.entities'; 'html' is not a package
如果我進入每個程序行到Python Shell它工作正常,並發現bs4等 我重新加載Python 3.4並重新安裝BeautifulSoup並請求並重新加載bs4文件從.zip文件 但沒有變化。就好像該運行從另一個庫執行。如果我從CMD線運行,我也會得到相同的結果。 代碼:
import requests, bs4
url="http://www.utexas.edu/world/univ/alpha/"
page = requests.get(url)
page.raise_for_status()
#soup = bs4.BeautifulSoup((page.text), "html.parser")
soup = bs4.BeautifulSoup((page.text),)
print("soup.title ", soup.title)
非常感謝,它總是顯而易見的答案 – Robertinspain