Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium WebDriver:socket.error:对等方重置连接_Python_Sockets_Python 2.7_Selenium - Fatal编程技术网

Python Selenium WebDriver:socket.error:对等方重置连接

Python Selenium WebDriver:socket.error:对等方重置连接,python,sockets,python-2.7,selenium,Python,Sockets,Python 2.7,Selenium,我正在尝试使用PhantomJS运行SeleniumWebDriver 每当我尝试执行: from selenium import webdriver x = webdriver.PhantomJS() x.get('any address') 我收到以下错误消息: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/P

我正在尝试使用PhantomJS运行SeleniumWebDriver

每当我尝试执行:

from selenium import webdriver
x = webdriver.PhantomJS()
x.get('any address')
我收到以下错误消息:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
     File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 176, in get
    self.execute(Command.GET, {'url': url})
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 162, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 350, in execute
    return self._request(url, method=command_info[0], data=data)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 382, in _request
    resp = self._conn.getresponse()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1045, in getresponse
    response.begin()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 409, in begin
    version, status, reason = self._read_status()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 365, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 476, in readline
    data = self._sock.recv(self._rbufsize)
socket.error: [Errno 54] Connection reset by peer
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
get中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/selenium/webdriver/remote/webdriver.py”,第176行
self.execute(Command.GET,{'url':url})
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/selenium/webdriver/remote/webdriver.py”,执行中第162行
响应=self.command\u executor.execute(driver\u command,params)
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/selenium/webdriver/remote/remote_connection.py”,第350行,在execute中
返回self.\u请求(url,方法=命令\u信息[0],数据=数据)
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/selenium/webdriver/remote/remote\u connection.py”,第382行,在请求中
resp=self.\u conn.getresponse()
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,第1045行,在getresponse中
response.begin()
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,第409行,在begin中
版本、状态、原因=self.\u读取\u状态()
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py”,第365行,处于“读取”状态
line=self.fp.readline(_MAXLINE+1)
readline中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py”,第476行
数据=self.\u sock.recv(self.\r bufsize)
socket.error:[Errno 54]对等方重置连接
有人知道会发生什么吗?我无法很好地理解socket.py中发生的事情,并且似乎无法跟踪_socket.pyd。此错误发生在本地计算机(OS X)上


很明显,最新的Selenium版本在phantomjs 1.9.2上运行不好。

您不是偶然使用了
urllib
,是吗?(假设您向我们展示的不是您的全部代码,可能是。)不,我导入的唯一模块是selenium.webdriverhmmm。我在Github上找到了。听起来真的很像你的。我不太了解硒的“幕后黑手”。但这可能与此有关,我在其他论坛的不同环境(CURL、json等)中也发现了类似的问题。
pip uninstall selenium
pip install selenium==2.3.7