Giter Club home page Giter Club logo

ValueError: Timeout value connect was <object object at 0x1034647c0>, but it must be an int, float or None about yt-videos-list HOT 2 OPEN

pradt avatar pradt commented on May 8, 2024
ValueError: Timeout value connect was , but it must be an int, float or None

from yt-videos-list.

Comments (2)

petejvig avatar petejvig commented on May 8, 2024 4

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

from yt-videos-list.

shailshouryya avatar shailshouryya commented on May 8, 2024 1

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!

from yt-videos-list.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.