我正在尝试在 pycharm 中使用 selenium 打开 firefox。我不知道问题是什么
I am trying to use selenium in pycharm to open firefox. I Have no idea what the problem is
我正在尝试在 pycharm 中使用 selenium 打开 firefox。我不知道是什么问题。
-我已经在正确的路径中安装了 geckodriver。 (/usr/local/bin)
-我正在使用 pop_os 20.04 LTS
当我运行
from selenium import webdriver
driver = webdriver.Chrome(r'/usr/local/bin')
*Traceback (most recent call last):
File "/home/elliot/PycharmProjects/IG/venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin': '/usr/local/bin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/elliot/PycharmProjects/IG/igbot.py", line 3, in <module>
driver = webdriver.Chrome(r'/usr/local/bin')
File "/home/elliot/PycharmProjects/IG/venv/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/home/elliot/PycharmProjects/IG/venv/lib/python3.7/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: 'bin' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1*
GeckoDriver 用于控制 Firefox 而您正在尝试使用 Chrome
driver = webdriver.Chrome(...
# ^^^^^^ ???
使用 Chrome驱动程序或切换到 Firefox。
将 r'/usr/local/bin'
传递给 Chrome
构造函数没有意义,假设可以在 PATH
.
中找到 GeckoDriver 或 ChromeDriver,您可以省略它
有一个很好的库可以自动执行繁琐的驱动程序管理任务,请参阅 webdriver-manager。
尝试阅读 selenium-python 文档的“安装”和“入门”章节。
我正在尝试在 pycharm 中使用 selenium 打开 firefox。我不知道是什么问题。
-我已经在正确的路径中安装了 geckodriver。 (/usr/local/bin) -我正在使用 pop_os 20.04 LTS
当我运行
from selenium import webdriver
driver = webdriver.Chrome(r'/usr/local/bin')
*Traceback (most recent call last):
File "/home/elliot/PycharmProjects/IG/venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin': '/usr/local/bin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/elliot/PycharmProjects/IG/igbot.py", line 3, in <module>
driver = webdriver.Chrome(r'/usr/local/bin')
File "/home/elliot/PycharmProjects/IG/venv/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/home/elliot/PycharmProjects/IG/venv/lib/python3.7/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: 'bin' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1*
GeckoDriver 用于控制 Firefox 而您正在尝试使用 Chrome
driver = webdriver.Chrome(...
# ^^^^^^ ???
使用 Chrome驱动程序或切换到 Firefox。
将 r'/usr/local/bin'
传递给 Chrome
构造函数没有意义,假设可以在 PATH
.
有一个很好的库可以自动执行繁琐的驱动程序管理任务,请参阅 webdriver-manager。
尝试阅读 selenium-python 文档的“安装”和“入门”章节。