Python selenium:webdriver.PhantomJS():“;错误:无法连接到端口51263上的GhostDriver“;

Python selenium:webdriver.PhantomJS():“;错误:无法连接到端口51263上的GhostDriver“;,python,selenium,phantomjs,ghostdriver,Python,Selenium,Phantomjs,Ghostdriver,我想在python3.4中使用PhantomJS()并键入 因此: from selenium import webdriver browser = webdriver.PhantomJS() 我得到了一个错误: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/dist-packages/selenium/w

我想在python3.4中使用PhantomJS()并键入

因此:

from selenium import webdriver
browser = webdriver.PhantomJS()
我得到了一个错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__
    self.service.start()
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/phantomjs/service.py", line 83, in start
    "Can not connect to GhostDriver on port {}".format(self.port))
selenium.common.exceptions.WebDriverException: Message: Can not connect to GhostDriver on port 40236
我找不到一个对我有效的解决方案,所以如果有人有想法的话,它将被创建

我的系统:

Linux controller 4.1.15-v7+ #830 SMP Tue Dec 15 17:02:45 GMT 2015 armv7l GNU/Linux

您必须下载phantomJS-

然后在代码中给出它的路径

browser = webdriver.PhantomJS(pathToPhantomJS)

您必须下载phantomJS-

然后在代码中给出它的路径

browser = webdriver.PhantomJS(pathToPhantomJS)

@Barkan感谢您的回复,但是安装了phantomjs并插入路径也不起作用。@Barkan感谢您的回复,但是安装了phantomjs并插入路径也不起作用。