Jupyter 笔记本 BeautifulSoup 导入错误
Jupyter Notebook BeautifulSoup ImportError
我是 python 开发人员的新手,最近在昨天 (https://www.continuum.io/downloads#windows)我的 windows 8 台机器。我立即启动了 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 安装 bs4
- 正在卸载和安装 anaconda 导航器中可用的 beautifulsoup4 和 beautifulsoup 包。
- conda 安装 HTMLParser --> 导致在 anaconda repos 上找不到包错误
- conda install bs4 --> 导致在 anaconda repos 上找不到包错误
我一直在努力让这个设置在笔记本中没有虚拟环境的情况下工作。我认为可以让它与根环境一起工作。
非常感谢任何对此问题的帮助!
我刚刚重新启动我的电脑,Jupyter Notebook 检测到 HTMLParser 模块。不确定我做了什么来实际修复它 - 但我猜答案是我在原始问题中列出的以下步骤之一,然后重新启动并再次启动 Jupyter。
我是 python 开发人员的新手,最近在昨天 (https://www.continuum.io/downloads#windows)我的 windows 8 台机器。我立即启动了 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 安装 bs4
- 正在卸载和安装 anaconda 导航器中可用的 beautifulsoup4 和 beautifulsoup 包。
- conda 安装 HTMLParser --> 导致在 anaconda repos 上找不到包错误
- conda install bs4 --> 导致在 anaconda repos 上找不到包错误
我一直在努力让这个设置在笔记本中没有虚拟环境的情况下工作。我认为可以让它与根环境一起工作。
非常感谢任何对此问题的帮助!
我刚刚重新启动我的电脑,Jupyter Notebook 检测到 HTMLParser 模块。不确定我做了什么来实际修复它 - 但我猜答案是我在原始问题中列出的以下步骤之一,然后重新启动并再次启动 Jupyter。