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

ValueError: Timeout value connect was <object object at 0x1034647c0>, but it must be an int, float or None #19

Open
pradt opened this issue May 23, 2023 · 2 comments

Comments

@pradt
Copy link

pradt commented May 23, 2023

Hi,
I'm facing the following error while executing the sample :

lc.create_list_for(url='https://www.youtube.com/user/schafer5') File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yt_videos_list/__init__.py", line 323, in create_list_for video_data, write_information = logic.execute(deque([url]), file_name, log_silently, *instance_attributes, _DummyLock()) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yt_videos_list/logic.py", line 198, in execute driver = open_user_driver() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yt_videos_list/logic.py", line 55, in open_user_driver return supported_drivers[user_driver]() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yt_videos_list/logic.py", line 60, in configure_firefoxdriver return webdriver.Firefox(options=options) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 170, in __init__ RemoteWebDriver.__init__( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__ self.start_session(capabilities, browser_profile) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute response = self.command_executor.execute(driver_command, params) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute return self._request(command_info[0], url, body=data) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request resp = self._conn.request(method, url, body=body, headers=headers) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/_request_methods.py", line 118, in request return self.request_encode_body( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/_request_methods.py", line 217, in request_encode_body return self.urlopen(method, url, **extra_kw) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 422, in urlopen conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 303, in connection_from_host return self.connection_from_context(request_context) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 328, in connection_from_context return self.connection_from_pool_key(pool_key, request_context=request_context) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 351, in connection_from_pool_key pool = self._new_pool(scheme, host, port, request_context=request_context) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 265, in _new_pool return pool_cls(host, port, **request_context) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/connectionpool.py", line 196, in __init__ timeout = Timeout.from_float(timeout) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/timeout.py", line 190, in from_float return Timeout(read=timeout, connect=timeout) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/timeout.py", line 119, in __init__ self._connect = self._validate_timeout(connect, "connect") File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/timeout.py", line 156, in _validate_timeout raise ValueError( ValueError: Timeout value connect was <object object at 0x1034647c0>, but it must be an int, float or None.

sample file was :
`from yt_videos_list import ListCreator

my_driver = 'firefox' # SUBSTITUTE DRIVER YOU WANT (options below)
lc = ListCreator(driver=my_driver, scroll_pause_time=0.8)

lc.create_list_for(url='https://www.youtube.com/user/schafer5')`

and I ran it as python3 sample.py. I'm not sure if I'm missing something here ?

my python version is 3.10.11

@petejvig
Copy link

I had the same issue, if you are not using urllib3 for any other modules, try downgrading it:

pip uninstall urllib3

pip install urllib3==1.26.5

@shailshouryya
Copy link
Owner

shailshouryya commented May 30, 2023

Hi pradt, thanks for filing this issue!

The TL;DR - urllib3 changed something internally, and anything that depends on urllib3 (selenium in this package) broke because of this urllib3 update. Fixing this error requires downloading an older urllib3 version that came out before the version released that contains this change (which appears to be 2.0.2), or a release after this change which fixes this error. Based on my local environment, urllib3 version 1.26.13 works, and based on the comment above, 1.26.5 works as well. To change your installed urllib3 version, run:

# on Linux/MacOS, might need to run pip3 or pip3.N (where N is your python minor version)
# instead of pip

pip uninstall urllib3
pip install urllib3==1.26.5 # or any other version that works

Explanation

I think petejvig's suggestion is a solid approach. Looking through the error you ran into:

lc.create_list_for(url='https://www.youtube.com/user/schafer5')
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yt_videos_list/__init__.py", line 323, in create_list_for
    video_data, write_information = logic.execute(deque([url]), file_name, log_silently, *instance_attributes, _DummyLock())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yt_videos_list/logic.py", line 198, in execute
    driver = open_user_driver()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yt_videos_list/logic.py", line 55, in open_user_driver
    return supported_drivers[user_driver]()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/yt_videos_list/logic.py", line 60, in configure_firefoxdriver
    return webdriver.Firefox(options=options)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 170, in __init__
    RemoteWebDriver.__init__(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
    return self._request(command_info[0], url, body=data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
    resp = self._conn.request(method, url, body=body, headers=headers)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/_request_methods.py", line 118, in request
    return self.request_encode_body(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/_request_methods.py", line 217, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 422, in urlopen
    conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 303, in connection_from_host
    return self.connection_from_context(request_context)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 328, in connection_from_context
    return self.connection_from_pool_key(pool_key, request_context=request_context)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 351, in connection_from_pool_key
    pool = self._new_pool(scheme, host, port, request_context=request_context)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/poolmanager.py", line 265, in _new_pool
    return pool_cls(host, port, **request_context)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/connectionpool.py", line 196, in __init__
    timeout = Timeout.from_float(timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/timeout.py", line 190, in from_float
    return Timeout(read=timeout, connect=timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/timeout.py", line 119, in __init__
    self._connect = self._validate_timeout(connect, "connect")
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/timeout.py", line 156, in _validate_timeout
    raise ValueError(
ValueError: Timeout value connect was <object object at 0x1034647c0>, but it must be an int, float or None.

it looks like this error is occurring because of some changes to the urllib3 package, which is a dependency the selenium package has. Specifically, the following looks like the relevant error here:

File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/timeout.py", line 156, in _validate_timeout
    raise ValueError(
ValueError: Timeout value connect was <object object at 0x1034647c0>, but it must be an int, float or None.

To test this, I ran the following snippet of code you included:

from yt_videos_list import ListCreator


my_driver = 'firefox' # SUBSTITUTE DRIVER YOU WANT (options below)
lc = ListCreator(driver=my_driver, scroll_pause_time=0.8)


lc.create_list_for(url='https://www.youtube.com/user/schafer5')

and this worked for me - so I'm pretty sure pinning urllib3 version to something earlier might fix your issue. For reference, I ran this with Python 3.10.0 (v3.10.0:b494f5935c, Oct 4 2021, 14:59:20) and my urllib3 version in this environment was

urllib3             1.26.13

If you use python for other projects and changing the urllib3 might cause problems for you, you can also

  • create a virtual environment with venv, which is a part of the standard Python library
  • download and install yt-videos-list in the virtual environment you create
  • update the urllib3 version in there (changing the urllib3 version inside this virtual environment won't affect any other projects you have).

This might look something like:

python -m venv myvenv

# examples below from https://docs.python.org/3/library/venv.html#how-venvs-work
myvenv\Scripts\activate.bat   # for cmd.exe (Command Prompt) on Windows
myvenv\Scripts\Activate.ps1   # for PowerShell on Windows
myvenv/bin/Activate.ps1     # for PowerShell on POSIX (based on your stack trace, I think you are on Windows, so this is probably irrelevant)

pip install yt-videos-list
pip uninstall urllib3
pip install urllib3==X.Y.Z # example: X.Y.Z can be 1.26.5

Related issues


Let me know if this addresses your issue, or if you have any questions about my explanation and would like me to explain something more!

Wolfe1 added a commit to Accruent/robotframework-applicationlibrary that referenced this issue Jun 12, 2023
@shailshouryya shailshouryya changed the title Error : Timeout value connect was <object object at 0x1034647c0>, but it must be an int, float or None ValueError: Timeout value connect was <object object at 0x1034647c0>, but it must be an int, float or None Jun 27, 2023
shailshouryya added a commit that referenced this issue Nov 7, 2023
- avoids problem described in issue #19
shailshouryya added a commit that referenced this issue Nov 10, 2023
- avoids problem described in issue #19
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