I dowloaded the latest versions of both selenium and geckodriver.
I did the following:
bash
cp Downloads/geckodriver /usr/local/bin/
PATH=$PATH:/usr/local/bin/geckodriver
python
from selenium import webdriver
browser = webdriver.Firefox()
error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/chris/anaconda/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 140, in __init__
self.service.start()
File "/Users/chris/anaconda/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/Users/chris/anaconda/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/Users/chris/anaconda/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
UPDATE
I did the same thing with chrome web driver:
browser = webdriver.Chrome()
error
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.12.3 x86_64)
Is this something to do with specifying the path?? Really confused as I am inexperienced with bash
Related
from selenium import webdriver
browser = webdriver.Firefox(executable_path="/usr/bin/geckodriver")
browser.get('http://www.ubuntu.com/')
The entire stack trace looks like:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 160, in __init__
self.service.start()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'geckodriver'
my path to geckodriver is:
/usr/bin/geckodriver
And selenium is in:
selenium in /usr/local/lib/python3.6/dist-packages (3.12.0)
Thanks in advance!
You have most probably installed a version of geckodriver that is meant for a different OS/platform! get the correct version from https://github.com/mozilla/geckodriver/releases and replace the one you have.
Use this command to install the latest chrome driver which supports selenium:
sudo apt-get install chromium-chromedriver
I basically want to use selenium on repl.it, but don't know how to do that. I tried installing chromedriver into repl.it but I still get this error:
Traceback (most recent call last):
File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 3, in <module>
driver = webdriver.Chrome()
File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in __init__
self.service.start()
File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
This is my code
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://youtube.com")
Try forking this Repl, it has working Selenium that you can use: Advanced Selenium Options
I'm having problems getting chromedriver to run on an AWS EC2 instance, using Ubuntu. As you can see from the image below, I've used FileZilla to drop chromedriver into my remote Ubuntu site, in the same folder as the Python script itself. I've then modified my python code to access the chromedriver from Ubuntu server, rather from my local path:
options = Options()
driverLocation = webdriver.Chrome(chrome_options=options,
executable_path=r'/home/ubuntu/bandsintown/chromedriver 4')
driverLocation.quit()
However, I'm getting the following error:
Traceback (most recent call last):
File "BandsInTown_Scraper_SF.py", line 33, in <module>
driverLocation = webdriver.Chrome(chrome_options=options, executable_path=r'/home/ubuntu/bandsintown/chromedriver 4')
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/ubuntu/bandsintown/chromedriver 4'
Image:
Try chromedriver\ 4 or remove the space from the filename.
Even though I have already put geckodriver in there and I restarted my computer, it still prints the same thing.
>>>from selenium import webdriver
>>>browser = webdriver.Firefox()
Traceback (most recent call last):
File "D:\Python\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "D:\Python\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "D:\Python\lib\subprocess.py", line 992, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in __init__
self.service.start()
File "D:\Python\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
And an error before that as well! Someone please help a newbie out. Image of the Path variable
You need to mention the path of the gecko driver executable. Below line will get you some idea.
driver=webdriver.Firefox(executable_path="add geckodriver.exe")
Hope this helps. Thanks.
Hi in Pycharm I have installed Selenium in virtualenv. I try execute
from selenium import webdriver
#from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
#binary = FirefoxBinary('/webdriver/firefox')
browser = webdriver.Firefox()
browser.get('http://localhost:8000')
assert 'Django ' in browser.title
but I have error
(django_env)darek#Toshiba:~/PycharmProjects/Django$ python
functional_tests.py Traceback (most recent call last): File
"functional_tests.py", line 5, in
browser = webdriver.Firefox() File "/home/darek/.virtualenvs/django_env/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py",
line 140, in init
self.service.start() File "/home/darek/.virtualenvs/django_env/lib/python3.5/site-packages/selenium/webdriver/common/service.py",
line 74, in start
stdout=self.log_file, stderr=self.log_file) File "/usr/lib/python3.5/subprocess.py", line 947, in init
restore_signals, start_new_session) File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg) NotADirectoryError: [Errno 20] Not a directory Exception ignored in: > Traceback (most recent call last): File
"/home/darek/.virtualenvs/django_env/lib/python3.5/site-packages/selenium/webdriver/common/service.py",
line 173, in del
self.stop() File "/home/darek/.virtualenvs/django_env/lib/python3.5/site-packages/selenium/webdriver/common/service.py",
line 145, in stop
if self.process is None: AttributeError: 'Service' object has no attribute 'process'
I download geckodriver ver. 11 and add to variable path and add in bashrc
export PYTHONPATH=${PYTHONPATH}:/usr/bin export
WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/MyProject
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 source
/usr/local/bin/virtualenvwrapper.sh
source django_env/bin/activate export
PATH=$PATH:/home/darek/webdriver/firefox/geckodriver export
PATH=$PATH:/home/darek/webdriver/firefox/wires
what can I do more?