dimmg / dockselpy

Dockerized Selenium and Python with support for Chrome, Firefox and PhantomJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Outdated Version of `urllib3`

axj336 opened this issue · comments

commented

Nice dockerfile, thanks! For anyone else, I got the following error after running the dockerfile and then executing docker exec <hash> python3 example.py.

INFO:root:Initialized virtual display..
INFO:root:Prepared chrome options..
Traceback (most recent call last):
  File "example.py", line 83, in <module>
    chrome_example()
  File "example.py", line 26, in chrome_example
    browser = webdriver.Chrome()#chrome_options=chrome_options)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 251, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 318, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py", line 375, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
    resp = self._conn.request(method, url, body=body, headers=headers)
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 79, in request
    **urlopen_kw)
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 142, in request_encode_body
    **urlopen_kw)
TypeError: urlopen() got multiple values for keyword argument 'body'

This is because I had version 1.7.1 of urllib3 installed in the image (I'm guessing this is the latest one in the repository. See this stackoverflow link

I fixed this issue by adding the following line RUN pip3 install urllib3 --upgrade to line 48 of the dockerfile. Pip complains about system packages but does install the correct one (you can check by adding RUN python3 -c "import urllib3; print(urllib3.__version__)" to the last line of the docker file)

Hi @axj336 ,

I just did a clean rebuild and the urllib3==1.23 got installed.
It is possible you were using a cached version of the image and you may try rebuilding it with the --no-cache option.

commented

Huh, that didn't work for me. Strange. I wonder if I am using an old version of Ubuntu:trusty. I'm happy to close this issue if you want to.

Maybe this happens if you are using the trusty image. Now the dockerfile is based on xenial image and I have not experienced any issues.

commented

Yep, looks like xenial fixes it.