Python 如何在windows系统上安装geckodriver
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42524114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to install geckodriver on a windows system
提问by Contro
I am trying to intall webdriver and in order to open firefox i need the geckodriver to be installed and in the correct path.
我正在尝试安装 webdriver,为了打开 Firefox,我需要安装 geckodriver 并安装在正确的路径中。
Firstly the download link to install geckodriver only allows you to install a file that is not an executable. So is there a way to make it an executable?
首先,安装 geckodriver 的下载链接只允许您安装一个不是可执行文件的文件。那么有没有办法让它成为可执行文件?
secondly I have tried to change my path variables in commmand prompt, but of course it didn't work. I then changed the user variable not the system path variables because there is not Path in system. there is a Path in user variables so I edited that to change where the file is located.
其次,我试图在命令提示符下更改我的路径变量,但当然没有用。然后我更改了用户变量而不是系统路径变量,因为系统中没有路径。用户变量中有一个路径,因此我对其进行了编辑以更改文件所在的位置。
I have extracted the geckodriver rar file and have received a file with no extension. I don't know how you can have a file with no extension, but they did it. The icon is like a blank sheet of paper with a fold at the top left.
我已经提取了 geckodriver rar 文件并收到了一个没有扩展名的文件。我不知道你怎么能有一个没有扩展名的文件,但他们做到了。该图标就像一张白纸,左上角有一个折叠。
If anyone has a solution for this including maybe another package that is like webdriver and will allow me to open a browser and then refresh the page after a given amount of time. this is all I want to do.
如果有人对此有解决方案,可能包括另一个类似于 webdriver 的包,它将允许我打开浏览器,然后在给定的时间后刷新页面。这就是我想要做的。
采纳答案by Contro
For one make sure you are downloading the one for your OS. Windows is at the bottom of the list it will say win32. Download that file or 64 doesn't matter.
一方面,请确保您正在为您的操作系统下载一个。Windows 位于列表的底部,它会显示 win32。下载该文件或 64 无关紧要。
After that you are going to want to extract the file. If you get an error that says there is no file in the Winrar file, this may be because in your Winrar settings you have Winrar set to not extract any files that have the extension .exe. If you go to Winrar options then settings then security you can delete this it will say *.exe, and after you delete that you can extract the file. After that is done, search how to update the path so that gecko driver can be accessed. Then you will most likely need to restart.
之后,您将要提取文件。如果您收到错误消息,指出 Winrar 文件中没有文件,这可能是因为在您的 Winrar 设置中,您将 Winrar 设置为不提取任何扩展名为 .exe 的文件。如果你去 Winrar 选项然后设置然后安全你可以删除它,它会显示 *.exe,删除后你可以提取文件。完成后,搜索如何更新路径,以便可以访问 gecko 驱动程序。然后您很可能需要重新启动。
回答by Hu Kenneth
You can put it anywhere. 1. put it into your project folder. 2. create a folder and put driver into it. Set the driver path up in your code.
你可以把它放在任何地方。1.把它放到你的项目文件夹中。2.创建一个文件夹并将驱动程序放入其中。在您的代码中设置驱动程序路径。
from selenium import webdriver
path="C:\Programs\Python36\BrowersDriver\chromedriver.exe"
driver=webdriver.Chrome(path)
driver.get("http://www.yahoo.com")
driver.close()
driver.quit()
http://kennethhutw.blogspot.sg/2017/03/how-to-install-geckodriver-on-windows.html
http://kennethhutw.blogspot.sg/2017/03/how-to-install-geckodriver-on-windows.html
回答by Higher Coding
First download GeckoDriverfor Windows, extract it and copy the path to the folder.
首先下载 GeckoDriverfor Windows,解压并将路径复制到文件夹中。
- Right-click on My Computer or This PC.
- Select Properties.
- Select advanced system settings.
- Click on the Environment Variables button.
- From System Variables select PATH.
- Click on Edit button.
- Click New button.
- Paste the path of GeckoDriver file.
- 右键单击我的电脑或这台电脑。
- 选择属性。
- 选择高级系统设置。
- 单击环境变量按钮。
- 从系统变量中选择 PATH。
- 单击编辑按钮。
- 单击新建按钮。
- 粘贴 GeckoDriver 文件的路径。
回答by FlyingZebra1
I've wrestled with the same question for last hour, and finally have a solution, which will hopefully help someone out there (Windows 10, Python 2.7, Anaconda distribution).
过去一个小时,我一直在为同样的问题苦苦挣扎,终于有了一个解决方案,希望对那里的人有所帮助(Windows 10、Python 2.7、Anaconda 发行版)。
1) This was the issue in my case: make sure you have the latest version of Firefox installed. I had firefox 36, which, when checking for updates, said it was the latest version. Mozilla's website had version 54 as latest. So download firefox from website, and reinstall
1) 这就是我的问题:确保您安装了最新版本的 Firefox。我有 Firefox 36,它在检查更新时说它是最新版本。Mozilla 网站的最新版本为 54。所以从网站下载firefox,然后重新安装
2) Make sure you have the latest gecko driver downloaded
2) 确保您下载了最新的 gecko 驱动程序
3) If you're getting the path error - use the code below to figure out which path python is looking at, and pop the geckodriver.exe in there:
3) 如果您收到路径错误 - 使用下面的代码找出 python 正在查看的路径,并在其中弹出 geckodriver.exe:
import os
os.getcwd()