Questions tagged [urllib3]

`urllib3` is a 3rd-party Python HTTP library with thread-safe connection pooling, file post, and more.

urllib3 is a library for python 2 and 3 providing a HTTP API with thread-safe connection pooling, file posting support, redirection handling and retries.

Documentation can be found at https://urllib3.readthedocs.io/en/latest/

760 questions
29
votes
2 answers

Cannot import requests.packages.urllib3.util 'Retry'

I am using Python 2.7 64 bit on Windows 8. I have Requests version 2.3 installed. I am trying to run this import statement as part of bringing in number of retries within my code: from requests.packages.urllib3.util import Retry I have urllib3…
gdogg371
  • 3,879
  • 14
  • 63
  • 107
27
votes
3 answers

What's the best way to download file using urllib3

I would like to download file over HTTP protocol using urllib3. I have managed to do this using following code: url = 'http://url_to_a_file' connection_pool = urllib3.PoolManager() resp = connection_pool.request('GET',url ) f = open(filename,…
running.t
  • 5,329
  • 3
  • 32
  • 50
26
votes
4 answers

Ignore certificate validation with urllib3

I'm using urllib3 against private services that have self signed certificates. Is there any way to have urllib3 ignore the certificate errors and make the request anyways? import urllib3 c = urllib3.HTTPSConnectionPool('10.0.3.168',…
Marco Ceppi
  • 7,163
  • 5
  • 31
  • 43
24
votes
3 answers

Using the Requests python library in Google App Engine

I'm trying to use the awesome Requests library on Google App Engine. I found a patch for urllib3, which requests relies on, that is compatible with App Engine. https://github.com/shazow/urllib3/issues/61 I can successfully import requests but…
rd108
  • 631
  • 2
  • 7
  • 14
22
votes
9 answers

No module named urllib3

I wrote a script to call an API and ran it successfully last week. This week, it won't run. I get back the following error message: Traceback (most recent call last): File "user_audit.py", line 2, in import requests File…
Jeremy Real
  • 726
  • 1
  • 6
  • 11
20
votes
7 answers

Obnoxious CryptographyDeprecationWarning because of missing hmac.compare_time function everywhere

Things were running along fine until one of my projects started printing this everywhere, at the top of every execution, at least once: local/lib/python2.7/site-packages/cryptography/hazmat/primitives/constant_time.py:26:…
Dustin Oprea
  • 9,673
  • 13
  • 65
  • 105
20
votes
9 answers

pip, proxy authentication and "Not supported proxy scheme"

Trying to install pip on a new python installation. I am stuck with proxy errors. Looks like a bug in get-pip or urllib3?? Question is do I have to go through the pain of setting up CNTLM as described here or is there a shortcut? get-pip.py…
Kashyap
  • 15,354
  • 13
  • 64
  • 103
17
votes
2 answers

Adding callback function on each retry attempt using requests/urllib3

I've implemented a retry mechanism to requests session using urllib3.util.retry as suggested both here and here. Now, I am trying to figure out what is the best way to add a callback function that will be called on every retry attempt. To explain…
A. Sarid
  • 3,916
  • 2
  • 31
  • 56
17
votes
1 answer

What is the purpose of mounting a Session object?

I have seen something like this in a few code snippets and in the Requests documentation: import requests sess = requests.Session() adapter = requests.adapters.HTTPAdapter(max_retries=20) sess.mount('https://', adapter) I am trying to get a better…
Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
17
votes
3 answers

Python requests with HTTPAdapter is halting for hours

I have a special URL where my code is halting for hours (more than 3 hours). I can't seem to understand why it would do that. The URL is http://www.etudes.ccip.fr/maintenance_site.php. Direct requests.get() works instantaneously but whenever I have…
fast_cen
  • 1,297
  • 3
  • 11
  • 28
16
votes
2 answers

Python Requests: IOError: [Errno 22] Invalid argument

I am new to Python Requests and am encountering an IOError:[Errno 22] Invalid argument when I attempt a requests.get(). In short, I am attempting to connect to an internal web application using SSL and so I pass a cert/key combination per the…
nacc
  • 311
  • 3
  • 8
16
votes
7 answers

How to fix ImportError: No module named packages.urllib3?

I'm running Python 2.7.6 on an Ubuntu machine. When I run twill-sh (Twill is a browser used for testing websites) in my Terminal, I'm getting the following: Traceback (most recent call last): File "dep.py", line 2, in import…
Joseph John
  • 510
  • 1
  • 5
  • 21
16
votes
6 answers

Python urllib3 and how to handle cookie support?

So I'm looking into urllib3 because it has connection pooling and is thread safe (so performance is better, especially for crawling), but the documentation is... minimal to say the least. urllib2 has build_opener so something…
bigredbob
  • 1,847
  • 4
  • 19
  • 19
16
votes
1 answer

Convert string to JSON in Python?

I'm trying to convert a string, generated from an http request with urllib3. Traceback (most recent call last): File "", line 1, in data = json.load(data) File "C:\Python27\Lib\json\__init__.py", line 286, in load …
bnlucas
  • 163
  • 1
  • 1
  • 4
15
votes
5 answers

Python urllib3 error - ImportError: cannot import name UnrewindableBodyError

I set my cronjob to call my script at particular time(ex- 2 4 5 10 * python3 mayank/exp/test.py). When my test.py is called I'm activating the virtualenv within my test.py script as follows. activate =…
Mayank Diwedi
  • 191
  • 1
  • 2
  • 7
1
2
3
50 51