2016-09-03 81 views
0

我是python开发新手,最近在我的Windows 8机器上安装了一个全新的64位版本的anaconda(使用python v。2.7.12)昨天(https://www.continuum.io/downloads#windows)。我立即发布了带有anaconda的Jupyter Notebook实例,并期望能够使用BeautifulSoup。当我notebook.ipynb文件执行这一行:from bs4 import BeautifulSoup我收到ImportErrorJupyter Notebook BeautifulSoup ImportError

ImportError        Traceback (most recent call last) 
<ipython-input-12-cbb98e44f096> in <module>() 
     9 #from yelp.oauth1_authenticator import Oauth1Authenticator 
    10 
---> 11 from bs4 import BeautifulSoup 

C:\Users\xxx\Anaconda2\lib\site-packages\bs4\__init__.py in <module>() 
    33 import warnings 
    34 
---> 35 from .builder import builder_registry, ParserRejectedMarkup 
    36 from .dammit import UnicodeDammit 
    37 from .element import (

C:\Users\xxx\Anaconda2\lib\site-packages\bs4\builder\__init__.py in <module>() 
    313 # to take precedence over html5lib, because it's faster. And we only 
    314 # want to use HTMLParser as a last result. 
--> 315 from . import _htmlparser 
    316 register_treebuilders_from(_htmlparser) 
    317 try: 

C:\Users\xxx\Anaconda2\lib\site-packages\bs4\builder\_htmlparser.py in <module>() 
     8  ] 
     9 
---> 10 from HTMLParser import HTMLParser 
    11 
    12 try: 

ImportError: cannot import name HTMLParser 

我已经试过:

  • PIP安装的HTMLParser
  • PIP安装BS4
  • 卸载和在anaconda导航器中安装beautifulsoup4和beautifulsoup软件包。
  • 畅达安装的HTMLParser - >导致包装内的蟒蛇回购错误未找到
  • 畅达安装BS4 - >导致包装内的蟒蛇回购错误未找到

我一直试图让这个集无需在笔记本电脑上使用虚拟环境。我认为它有可能使它与root env一起工作。

任何有关这个问题的帮助将不胜感激!

+0

这很奇怪... ['HTMLParser'](// docs.python.org/2/library/htmlparser.html)应该在Python 2.2+的标准库中,并且只能在Python 3中重命名为'html.parser'。 –

+0

注意:在安装anaconda之前,我已经卸载了所有版本的python(2.7.12和3.5)。 – miniscem

回答

0

我刚刚重新启动我的电脑,Jupyter Notebook检测到HTMLParser模块。不知道我做了什么来修复它 - 但我猜测答案是我在原始问题中列出的以下步骤之一,然后重新启动并启动Jupyter。