无法在 Ubuntu 14.04 中安装 Selenium Python 模块

无法在 Ubuntu 14.04 中安装 Selenium Python 模块

我无法安装 Selenium Python 模块。我已尝试过sudo pip3 install -U selenium

我实际上尝试在虚拟环境中安装它。但出现了错误。

很久以前,我安装了 pip3 和 virtualenv

sudo apt-get install python3-pip
sudo pip3 install virtualenv

这是回溯

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python3/dist-packages/pip/req.py", line 1197, in prepare_files
    do_download,
  File "/usr/lib/python3/dist-packages/pip/req.py", line 1375, in unpack_url
    self.session,
  File "/usr/lib/python3/dist-packages/pip/download.py", line 572, in unpack_http_url
    download_hash = _download_url(resp, link, temp_location)
  File "/usr/lib/python3/dist-packages/pip/download.py", line 433, in _download_url
    for chunk in resp_read(4096):
  File "/usr/lib/python3/dist-packages/pip/download.py", line 421, in resp_read
    chunk_size, decode_content=False):
  File "/usr/lib/python3/dist-packages/urllib3/response.py", line 225, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/lib/python3/dist-packages/urllib3/response.py", line 174, in read
    data = self._fp.read(amt)
  File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
  File "/usr/lib/python3.4/http/client.py", line 539, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.4/ssl.py", line 746, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.4/ssl.py", line 618, in read
    v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

答案1

您正在尝试在 Python 虚拟环境中安装 Python 3 模块 (python-virtualenv) 特定于 Python 2.x。为了使用 pip3 在 Ubuntu 14.04 中安装 Python 3 模块,您必须按照以下说明为 Python 3.x 创建 Python 虚拟环境这个答案。然后就可以使用 pip3 在新的 Pyvenv 虚拟环境中安装 Selenium 模块了。Selenium 模块最新版本支持的 Python 3.x 版本是 Python 3.2 和 Python 3.3,所以不能使用 pip3.4 安装此模块,只能使用 pip3。

相关内容