docker中安装pyppeteer,解决ImportError: cannot import name 'Deque'问题
问题:在以centos7为基础镜像的docker容器中安装pyppeteer后,报了如下错误>>> import pyppeteerTraceback (most recent call last):File "<stdin>", line 1, in <module>File "/usr/local/python3/lib/pyt...
·
问题:
在以centos7为基础镜像的docker容器中安装pyppeteer后,报了如下错误
>>> import pyppeteer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python3/lib/python3.6/site-packages/pyppeteer/__init__.py", line 30, in <module>
from pyppeteer.launcher import connect, launch, executablePath # noqa: E402
File "/usr/local/python3/lib/python3.6/site-packages/pyppeteer/launcher.py", line 24, in <module>
from pyppeteer.browser import Browser
File "/usr/local/python3/lib/python3.6/site-packages/pyppeteer/browser.py", line 13, in <module>
from pyppeteer.connection import Connection
File "/usr/local/python3/lib/python3.6/site-packages/pyppeteer/connection.py", line 12, in <module>
import websockets
File "/usr/local/python3/lib/python3.6/site-packages/websockets/__init__.py", line 3, in <module>
from .auth import *
File "/usr/local/python3/lib/python3.6/site-packages/websockets/auth.py", line 15, in <module>
from .server import HTTPResponse, WebSocketServerProtocol
File "/usr/local/python3/lib/python3.6/site-packages/websockets/server.py", line 49, in <module>
from .protocol import WebSocketCommonProtocol
File "/usr/local/python3/lib/python3.6/site-packages/websockets/protocol.py", line 18, in <module>
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
>>>
完毕!
更多推荐
已为社区贡献4条内容
所有评论(0)