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

typeError: __init__() got an unexpected keyword argument 'options' #22

Closed
liqing1990 opened this issue Aug 11, 2020 · 2 comments
Closed

Comments

@liqing1990
Copy link

The following is my environment and code
MacOS Mojave 10.14.4
chrome:84

import undetected_chromedriver as uc
chromedriver_path='./chromedriver'
uc.install(executable_path=chromedriver_path)
from selenium.webdriver import Chrome,ChromeOptions
option = ChromeOptions()
option.add_argument('--disable-popup-blocking')
driver = Chrome(chrome_options=option)
driver.get('https://distilnetworks.com')

The following is the error message

Selenium patched. Safe to import Chrome / ChromeOptions
Selenium patched. Safe to import Chrome / ChromeOptions
Selenium patched. Safe to import Chrome / ChromeOptions
Selenium patched. Safe to import Chrome / ChromeOptions
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1664, in
main()
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1068, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/mac_lee/Documents/iCollections/work/python/workspace/bet365_spider/test0810.py", line 11, in
driver = Chrome(chrome_options=option)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/undetected_chromedriver/init.py", line 49, in new
instance.init(*args, **kwargs)
TypeError: init() got an unexpected keyword argument 'options'

Can you know why this is?

@ultrafunkamsterdam
Copy link
Owner

ultrafunkamsterdam commented Aug 11, 2020

Hi there @liqing1990 ,

I'm not sure about this, but i cannot find a single thing that is correct, even the exception :
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/undetected_chromedriver/init.py", line 49, in new instance.init(*args, **kwargs) TypeError: init() got an unexpected keyword argument 'options'

does not point to a file included in this library (init.py). Either you made modifications yourself or whatnot, but my recommendation: Please install the latest version of python and this package, and please first try importing and using it as described in the README.md (options are all be taken care of) :

import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get('https://distilnetworks.com')

Also, you don't need to import Chrome and ChromeOptions from selenium (well you can and it should work, but i don't see any reason for it in your use case). You can use uc.ChromeOptions and uc.Chrome as well. Also specifying the executable path is not needed, since these options are included by default. Furthermore. Chrome accepts an options parameter but not chrome_options.

(i tested it on Mojave as well and it worked out of the box)

Kind regards

@chryahya
Copy link

chryahya commented Sep 6, 2020

Hi, i have the same error
My environement : windows server 2012, Chrome Last version, python 3.7 & python 3.8

My Code :
import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get('https://distilnetworks.com')

The Error :
/python3.8/site-packages/undetected_chromedriver/init.py", line 49, in new instance.init(*args, **kwargs) TypeError: init() got an unexpected keyword argument 'options'

This is the screenshot :
https://i.ibb.co/PMPts9L/Error-bot.png

NOTE :
i have two windows server 2012 with the same configuration and same chrome & python & same code
one of them work well, and the other i have the error.

Thank you

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

No branches or pull requests

3 participants