beautifulsoup4无法安装,但出现redis错误

时间:2019-11-09 12:52:37

标签: python beautifulsoup redis

在Ubuntu 18 / python 3.5上。我安装的beautifulsoup 4失败,并在错误消息中提及redis服务器。我确实在这台机器上安装了redis。不确定bs4安装为何会受其干扰(请参阅下面的安装错误)。我尝试忽略该问题,然后运行示例bs4测试,该测试随后失败。不知道解析失败是否与错误安装有关。

从bs4导入BeautifulSoup

html_doc = """
<html><head><title>The Dormouse's story</title></head>
"""

soup = BeautifulSoup(html_doc, "html5lib")
print(soup.prettify)

html.parser和html5lib均产生如下错误:

Traceback (most recent call last):
  File "/srv/raiddisk/dev/pythonInterviews/src/HTML_beautsoup.py", line 1, in <module>
    from bs4 import BeautifulSoup
  File "/usr/lib/python3/dist-packages/bs4/__init__.py", line 30, in <module>
    from .builder import builder_registry, ParserRejectedMarkup
  File "/usr/lib/python3/dist-packages/bs4/builder/__init__.py", line 314, in <module>
    from . import _html5lib
  File "/usr/lib/python3/dist-packages/bs4/builder/_html5lib.py", line 70, in <module>
    class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: module 'html5lib.treebuilders' has no attribute '_base'

bs4错误的安装:

(venv) marshall@samson:/srv/raiddisk/dev/pythonInterviews$ sudo apt-get install --reinstall python3-bs4
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-154 linux-headers-4.4.0-154-generic
  linux-headers-4.4.0-164 linux-headers-4.4.0-164-generic
  linux-modules-4.4.0-164-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 61 not upgraded.
1 not fully installed or removed.
Need to get 64.1 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://mirrors.cs.umass.edu/ubuntu xenial/main amd64 python3-bs4 all 4.4.1-1 [64.1 kB]
Fetched 64.1 kB in 0s (116 kB/s)     
(Reading database ... 371175 files and directories currently installed.)
Preparing to unpack .../python3-bs4_4.4.1-1_all.deb ...
Unpacking python3-bs4 (4.4.1-1) over (4.4.1-1) ...
Setting up redis-server (2:3.0.6-1ubuntu0.4) ...
Job for redis-server.service failed because the control process exited with error code. See "systemctl status redis-server.service" and "journalctl -xe" for details.
invoke-rc.d: initscript redis-server, action "start" failed.
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sat 2019-11-09 07:33:59 EST; 6ms ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 77504 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=1/FAILURE)
  Process: 77497 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d (code=exited, status=0/SUCCESS)

Nov 09 07:33:59 samson systemd[1]: Failed to start Advanced key-value store.
Nov 09 07:33:59 samson systemd[1]: redis-server.service: Unit entered faile...e.
Nov 09 07:33:59 samson systemd[1]: redis-server.service: Failed with result...'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package redis-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python3-bs4 (4.4.1-1) ...
Errors were encountered while processing:
 redis-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

0 个答案:

没有答案