Python 3.x Mac:将.exe保存到selenium web驱动程序的路径
我不是一个专业的开发人员。。。试图将chromedriver保存到PATH变量,这样我就可以在python中使用selenium了 请按照本页的说明进行操作 我使用Python 3.x Mac:将.exe保存到selenium web驱动程序的路径,python-3.x,selenium-webdriver,path,Python 3.x,Selenium Webdriver,Path,我不是一个专业的开发人员。。。试图将chromedriver保存到PATH变量,这样我就可以在python中使用selenium了 请按照本页的说明进行操作 我使用nano.bash\u配置文件打开bash\u配置文件 我创建了一个目录user/myusername/selenium/ 然后用python脚本i和selenium将我的文件chromedriver保存在此目录中。 我已尝试保存chromedriver.exe文件的路径 export PATH=“/User/baldoa/sele
nano.bash\u配置文件打开bash\u配置文件
我创建了一个目录user/myusername/selenium/
然后用python脚本i和selenium将我的文件chromedriver
保存在此目录中。
我已尝试保存chromedriver.exe文件的路径
export PATH=“/User/baldoa/selenium/ChromeDriver.exe:$PATH”
我按照以下步骤根据此页面进行适当保存。我不确定
我仍然得到以下错误:
a8206602016e:selenium baldoa$ python destruction.py
Traceback (most recent call last):
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/subprocess.py", line
709, in __init__
restore_signals, start_new_session)
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/subprocess.py", line
1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:/users/baldoa
/selenium/chromedriver.exe': 'C:/users/baldoa/selenium/chromedriver.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "destruction.py", line 7, in <module>
browser = webdriver.Chrome("""C:/users/baldoa/selenium/chromedriver.exe""")
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe'
executable needs to be in PATH. Please see https://sites.google.com
/a/chromium.org/chromedriver/home
a8206602016e:selenium baldoa$python destruction.py
回溯(最近一次呼叫最后一次):
文件“/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/common/service.py”,第76行,开始
标准偏差=管道)
文件“/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/subprocess.py”,第行
709,在初始__
恢复信号,启动新会话)
文件“/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/subprocess.py”,第行
1344年,在执行子
引发子项异常类型(错误号、错误消息、错误文件名)
FileNotFoundError:[Errno 2]没有这样的文件或目录:'C:/users/baldoa
/selenium/chromedriver.exe':'C:/users/baldoa/selenium/chromedriver.exe'
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“destruction.py”,第7行,在
browser=webdriver.Chrome(““C:/users/baldoa/selenium/chromedriver.exe”)
文件“/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/chrome/webdriver.py”,第68行,在__
self.service.start()
文件“/Users/baldoa/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium
/webdriver/common/service.py”,第83行,开始
os.path.basename(self.path)、self.start\u错误消息)
selenium.common.exceptions.WebDriverException:消息:“chromedriver.exe”
可执行文件需要在路径中。请看https://sites.google.com
/a/chromium.org/chromedriver/home
请粘贴驱动程序实例化代码。这将有助于理解。另外,当您使用mac时,为什么需要C:\呢?与.exe扩展名相同?-我不知道如何查看此驱动程序的代码,但这里是指向该驱动程序的链接将其更改为browser=webdriver.Chrome(“'Users/baldoa/selenium/chromedriver”“”)
和'export PATH=“/User/baldoa/selenium/bin:$PATH”`在命令提示符中键入pwd
后,我现在可以看到Users/baldoa
。。。我不确定这是怎么回事。。。我应该创建一个文件路径吗?文件所在的文件夹。。。它位于名为seleniumby code的目录中,我指的是您为打开浏览器窗口而编写的代码。