繁体   English   中英

Jupyter Notebook BeautifulSoup ImportError

[英]Jupyter Notebook BeautifulSoup ImportError

我是python dev的新手,最近在我的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我收到一个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 install bs4
  • 卸载并安装anaconda导航器中提供的beautifulsoup4和beautifulsoup软件包。
  • conda安装HTMLParser - >导致在anaconda repos错误上找不到包
  • conda install bs4 - >导致在anaconda repos错误中找不到包

我一直试图让这个设置在笔记本电脑中没有虚拟环境的情况下工作。 我认为有可能让它与root env一起工作。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM