FAQ
Troubleshooting
Last updated 01 August 2017

Python "Timeout value connect must be an int or float" error

While using our python client some customers encounter the following error message:

AlgoliaException: Unreachable hosts:
'{APPLICATION-ID}-3.algolianet.com':
'ValueError: Timeout value connect was (5, 50), but it must be an int or float.',
'{APPLICATION-ID}-1.algolianet.com':
'ValueError: Timeout value connect was (1, 30), but it must be an int or float.',
'{APPLICATION-ID}-2.algolianet.com':
'ValueError: Timeout value connect was (3, 40), but it must be an int or float.',
'{APPLICATION-ID}.algolia.net':
'ValueError: Timeout value connect was (1, 30), but it must be an int or float.'

This is due to an incompatible version of the requests python library. The minimum version needed for our client is the 2.9.1, anything below is not expected to work. To ensure the version of the requests package is the one you think:

python -c 'import requests; print(requests.__version__)'

This version number may not be the one you expect: this is due to this library being able to be installed both by the python package manager (pip) and the system package manager (dpkg, pacman, apt, yum, portage…). The system package manager may ship an old version of the library and depending on the setup, this one may take precedence over the one installed by pip.

To solve this issue, you can use python virtual environments to isolate your installed libraries from the system’s.