Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError for installation with GeckoDriverManager #273

Closed
heinp opened this issue Nov 12, 2021 · 6 comments · Fixed by #279
Closed

JSONDecodeError for installation with GeckoDriverManager #273

heinp opened this issue Nov 12, 2021 · 6 comments · Fixed by #279

Comments

@heinp
Copy link

heinp commented Nov 12, 2021

Recently (first time noticed it last week) when trying to install GeckoDriver using the GeckoDriverManager it freezes for a couple minutes on Trying to download new driver from […] and then raises a JSONDecodeError while trying to raise a ValueError indicating it didn't receive a 200 response. I do have an active internet connection.

Version of webdriver_manager: 3.2.1
OS: Arch

>>> from webdriver_manager.firefox import GeckoDriverManager
>>> exec_path = GeckoDriverManager().install()


[WDM] - ====== WebDriver manager ======
[WDM] - There is no [linux64] geckodriver for browser  in cache
[WDM] - Getting latest mozilla release info for v0.30.0
[WDM] - Trying to download new driver from https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/x/.local/lib/python3.9/site-packages/webdriver_manager/firefox.py", line 29, in install
    return self._get_driver_path(self.driver)
  File "/home/x/.local/lib/python3.9/site-packages/webdriver_manager/manager.py", line 28, in _get_driver_path
    file = download_file(driver.get_url())
  File "/home/x/.local/lib/python3.9/site-packages/webdriver_manager/utils.py", line 93, in download_file
    validate_response(response)
  File "/home/x/.local/lib/python3.9/site-packages/webdriver_manager/utils.py", line 81, in validate_response
    raise ValueError(resp.json())
  File "/usr/lib/python3.9/site-packages/requests/models.py", line 901, in json
    return complexjson.loads(
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
@heinp
Copy link
Author

heinp commented Nov 12, 2021

Updated to webdriver_manager v. 3.5.2. The problem persists.
Here is the updated error message:

In [2]: GeckoDriverManager().install()


====== WebDriver manager ======
Current firefox version is 94.0
Get LATEST geckodriver version for 94.0 firefox
There is no [linux64] geckodriver for browser  in cache
Getting latest mozilla release info for v0.30.0
Trying to download new driver from https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-2-631d1e06b13f> in <module>
----> 1 GeckoDriverManager().install()

~/.local/lib/python3.9/site-packages/webdriver_manager/firefox.py in install(self)
     27 
     28     def install(self):
---> 29         return self._get_driver_path(self.driver)

~/.local/lib/python3.9/site-packages/webdriver_manager/manager.py in _get_driver_path(self, driver)
     28             return binary_path
     29 
---> 30         file = download_file(driver.get_url(), driver.ssl_verify)
     31         binary_path = self.driver_cache.save_file_to_cache(file, browser_version,
     32                                                            driver_name, os_type, driver_version)

~/.local/lib/python3.9/site-packages/webdriver_manager/utils.py in download_file(url, ssl_verify)
     96     log(f"Trying to download new driver from {url}")
     97     response = requests.get(url, stream=True, verify=ssl_verify)
---> 98     validate_response(response)
     99     return File(response)
    100 

~/.local/lib/python3.9/site-packages/webdriver_manager/utils.py in validate_response(resp)
     81     elif resp.status_code != 200:
     82         raise ValueError(
---> 83             f'response body:\n{resp.json()}\n'
     84             f'request url:\n{resp.request.url}\n'
     85             f'response headers:\n{dict(resp.headers)}\n'

/usr/lib/python3.9/site-packages/requests/models.py in json(self, **kwargs)
    899             if encoding is not None:
    900                 try:
--> 901                     return complexjson.loads(
    902                         self.content.decode(encoding), **kwargs
    903                     )

/usr/lib/python3.9/json/__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    344             parse_int is None and parse_float is None and
    345             parse_constant is None and object_pairs_hook is None and not kw):
--> 346         return _default_decoder.decode(s)
    347     if cls is None:
    348         cls = JSONDecoder

/usr/lib/python3.9/json/decoder.py in decode(self, s, _w)
    335 
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()
    339         if end != len(s):

/usr/lib/python3.9/json/decoder.py in raw_decode(self, s, idx)
    353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@Bisteccowner
Copy link

I solved a problem like this for Chrome, using:

os.environ['WDM_LOCAL'] = '1'

#270

@heinp
Copy link
Author

heinp commented Nov 24, 2021

I solved a problem like this for Chrome, using:

os.environ['WDM_LOCAL'] = '1'

#270

Thanks, but this doesn't work. Error persists.

@rachmadaniHaryono
Copy link
Contributor

@heinp can you try #279

it will not fix your actual error with webdriver_manager but it will print out actual error instead of jsondecodeerror

@heinp
Copy link
Author

heinp commented Dec 10, 2021

@heinp can you try #279

it will not fix your actual error with webdriver_manager but it will print out actual error instead of jsondecodeerror

With that it works perfectly, there is no error at all anymore. Is this weird? Thanks though!

@rachmadaniHaryono
Copy link
Contributor

With that it works perfectly, there is no error at all anymore. Is this weird?

yes, if everything is working correctly and actual error is not yet resolved, there should be ValueError instead of jsondecodeerror

if not i think it could be fixed and you may not even need the pr

aleksandr-kotlyar added a commit to aleksandr-kotlyar/webdriver_manager that referenced this issue Feb 7, 2022
aleksandr-kotlyar added a commit to aleksandr-kotlyar/webdriver_manager that referenced this issue Feb 8, 2022
aleksandr-kotlyar added a commit to aleksandr-kotlyar/webdriver_manager that referenced this issue Feb 8, 2022
- fix tests utils
- fix/stabilize tests with selenium
aleksandr-kotlyar added a commit to aleksandr-kotlyar/webdriver_manager that referenced this issue Feb 8, 2022
- fix tests utils
- fix/stabilize tests with selenium
aleksandr-kotlyar added a commit to aleksandr-kotlyar/webdriver_manager that referenced this issue Feb 8, 2022
- fix tests utils
- fix/stabilize tests
aleksandr-kotlyar added a commit to aleksandr-kotlyar/webdriver_manager that referenced this issue Feb 8, 2022
- fix test utils
- update CHANGELOG.md with SergeyPirogov#273
SergeyPirogov pushed a commit that referenced this issue Feb 8, 2022
- fix test utils
- update CHANGELOG.md with #273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants