docker中安装pyppeteer,解决ImportError: cannot import name 'Deque'问题

问题:

在以centos7为基础镜像的docker容器中安装pyppeteer后,报了如下错误

>>> import pyppeteer
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/python3/lib/python3.6/site-packages/pyppeteer/__init__.py", line 30, in 
    from pyppeteer.launcher import connect, launch, executablePath  # noqa: E402
  File "/usr/local/python3/lib/python3.6/site-packages/pyppeteer/launcher.py", line 24, in 
    from pyppeteer.browser import Browser
  File "/usr/local/python3/lib/python3.6/site-packages/pyppeteer/browser.py", line 13, in 
    from pyppeteer.connection import Connection
  File "/usr/local/python3/lib/python3.6/site-packages/pyppeteer/connection.py", line 12, in 
    import websockets
  File "/usr/local/python3/lib/python3.6/site-packages/websockets/__init__.py", line 3, in 
    from .auth import *
  File "/usr/local/python3/lib/python3.6/site-packages/websockets/auth.py", line 15, in 
    from .server import HTTPResponse, WebSocketServerProtocol
  File "/usr/local/python3/lib/python3.6/site-packages/websockets/server.py", line 49, in 
    from .protocol import WebSocketCommonProtocol
  File "/usr/local/python3/lib/python3.6/site-packages/websockets/protocol.py", line 18, in 
    from typing import (
ImportError: cannot import name 'Deque'

解决办法:

1. 删除刚安装的pyppeteer

pip3 uninstall pyppeteer

2.删除websockets并安装websockets==6.0

# 删除
pip uninstall websockets
# 安装
pip install websockets==6.0

3.重新安装pyppeteer

pip install pyppeteer

结果:

Python 3.6.0 (default, Aug 22 2019, 12:52:43) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyppeteer
>>> 

完毕!

你可能感兴趣的:(数据采集)