<ol>
<li>Selenium用于引用名为<code>wires.exe</code>(<a href="https://github.com/mozilla/geckodriver/issues/90#issuecomment-226154811" rel="nofollow noreferrer">github-geckodriver issue 90</a>)的驱动程序。从<code>Selenium3</code>起,该驱动程序已替换为<code>geckodriver.exe</code>。通过运行<code>pip install "selenium>=3.0.0"</code>安装/升级到最新的selenium</li>
<li><a href="https://github.com/mozilla/geckodriver/releases/tag/v0.11.1" rel="nofollow noreferrer">Download the latest geckodriver</a>适用于您的平台:截至本文撰写之时,64位的{<cd5>}或32位的{<cd6>}。在您的例子中,<code>version %1</code>错误与错误的geckodriver版本有关。将此zip解压缩到<code>C:\Users\YourUserName\Downloads\selenium_driver</code></li>
<li>安装<a href="https://www.mozilla.org/en-US/firefox/organizations/all/?q=English%20(US)" rel="nofollow noreferrer">Firefox Extended Support Release</a>,将自定义安装路径设置为<code>C:\Program Files\Mozilla FirefoxESR</code>(如果是64位的话)或{<cd10>}(如果是32位的话)。在</li>
</ol>
<p>如果<a href="http://www.computerhope.com/issues/ch000549.htm" rel="nofollow noreferrer">setting the Windows PATH</a>到{<cd8>}似乎不起作用(这样<code>selenium</code>可以找到<code>geckdriver.exe</code>),则可以改为在Python脚本中指定其目录,如下所示:</p>
<pre><code>from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
gecko = r'C:\Users\YourUserName\Downloads\selenium_driver\geckodriver.exe'
ffox_binary = FirefoxBinary(r'C:\Program Files\Mozilla FirefoxESR\firefox.exe') #for 64 bit installation
#ffox_binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla FirefoxESR\firefox.exe') #for 32 bit installation
browser = webdriver.Firefox(firefox_binary=ffox_binary, executable_path=gecko)
browser.get('http://localhost:8000')
</code></pre>