Comments (12)
Which version of Python are you using?
On Mar 27, 2012 5:50 AM, "MOON-CLJ" <
[email protected]>
wrote:
from urllib3 import HTTPSConnectionPool
File
"/usr/local/lib/python2.7/dist-packages/urllib3-1.3-py2.7.egg/urllib3/init.py",
line 22, in
from . import exceptions
ImportError: cannot import name exceptionswith easy_install
Reply to this email directly or view it on GitHub:
#65
from urllib3.
2.7
from urllib3.
Ah should have seen it in the path. I'm having trouble reproducing it though...
$ easy_install -U urllib3
Searching for urllib3
Reading http://pypi.python.org/simple/urllib3/
Reading https://github.com/shazow/urllib3
Reading http://code.google.com/p/urllib3/
Reading http://urllib3.readthedocs.org/
Best match: urllib3 1.3
Downloading http://pypi.python.org/packages/source/u/urllib3/urllib3-1.3.tar.gz#md5=6ae9acdaee2628b1c8b1de25b7e6c9da
Processing urllib3-1.3.tar.gz
Running urllib3-1.3/setup.py -q bdist_egg --dist-dir /var/folders/++/++7MiU++6+0++4RjPqRgNE+0K9c/-Tmp-/easy_install-RyJmpc/urllib3-1.3/egg-dist-tmp-MKXgRp
zip_safe flag not set; analyzing archive contents...
dummyserver.server: module references __file__
Adding urllib3 1.3 to easy-install.pth file
Installed /Users/shazow/env/urllib3/lib/python2.7/site-packages/urllib3-1.3-py2.7.egg
Processing dependencies for urllib3
Finished processing dependencies for urllib3
Any ideas?
from urllib3.
Ah, just noticed you meant the error happens on import, not install. Checking.
from urllib3.
Hmm, seems to work during import too:
$ python
Python 2.7.2 (default, Dec 16 2011, 19:20:09)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib3 import HTTPSConnectionPool
>>> import urllib3
>>> urllib3.exceptions
<module 'urllib3.exceptions' from '/Users/shazow/env/urllib3/lib/python2.7/site-packages/urllib3-1.3-py2.7.egg/urllib3/exceptions.pyc'>
>>>
from urllib3.
oh i know, i check this
it's just because i used eventlet.import_patched
urllib3 = eventlet.import_patched('urllib3')
from urllib3 import HTTPSConnectionPool
but with version 1.2.2 this will be fine
from urllib3.
Ah, that is indeed a problem. Any interest in fixing it? :)
I was hoping to have exceptions available under urllib3.exceptions
without an extra import if possible.
from urllib3.
ok i'll try to do this
from urllib3.
clj@clj-laptop:~/dev$ sudo easy_install urllib3==1.2.2
Searching for urllib3==1.2.2
Best match: urllib3 1.2.2
Processing urllib3-1.2.2-py2.7.egg
urllib3 1.2.2 is already the active version in easy-install.pth
Using /usr/local/lib/python2.7/dist-packages/urllib3-1.2.2-py2.7.egg
Processing dependencies for urllib3==1.2.2
Finished processing dependencies for urllib3==1.2.2
clj@clj-laptop:~/dev$ python
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import eventlet
urllib3 = eventlet.import_patched('urllib3')
from urllib3 import exceptions
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name exceptions
after viewing the source code of eventlet
i think this is just a eventlet.import_patched bug(as shown above)
but i still dont know exactly where is the bug in eventlet
i'll check it again later
if you have times, you can check this
https://bitbucket.org/which_linden/eventlet/src/a60be8a9cdb5/eventlet/patcher.py
if you find what causes this,
please let me know
thanks in advance
from urllib3.
urllib3 version 1.2.2
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import eventlet
>>> urllib3 = eventlet.import_patched('urllib3')
>>> dir(urllib3)
['HTTPConnectionPool', 'HTTPError', 'HTTPResponse', 'HTTPSConnectionPool', 'MaxRetryError', 'PoolManager', 'ProxyManager', 'SSLError', 'TimeoutError', '__author__', '__builtins__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__version__', '_collections', 'connection_from_url', 'connectionpool', 'encode_multipart_formdata', 'exceptions', 'filepost', 'get_host', 'make_headers', 'packages', 'poolmanager', 'proxy_from_url', 'request', 'response']
>>> import urllib3
>>> dir(urllib3)
['HTTPConnectionPool', 'HTTPError', 'HTTPResponse', 'HTTPSConnectionPool', 'MaxRetryError', 'PoolManager', 'ProxyManager', 'SSLError', 'TimeoutError', '__author__', '__builtins__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__version__', 'connection_from_url', 'encode_multipart_formdata', 'get_host', 'make_headers', 'proxy_from_url']
after import urllib3
some attributes were lost
from urllib3.
Hmm, here's the set difference:
['_collections',
'request',
'connectionpool',
'filepost',
'poolmanager',
'exceptions',
'packages',
'response']
from urllib3.
it's not necessary to use eventlet.import_patched('urllib3')(but the bug is existed exactly)
eventlet.patcher.monkey_patch() can patch all the modules that eventlet can provide
so
eventlet.patcher.monkey_patch()
import urllib3
it will work for me
from urllib3.
Related Issues (20)
- Path toward testing with a released version of hypercorn? HOT 3
- Handle HTTP/2 informational responses (1xx) HOT 2
- urllib3 2.2 explicitly casts all headers to HTTPHeaderDict HOT 4
- Streaming responses using urllib3 HOT 5
- verbose logging output
- Excess leading path separators causes ConnectionPool.urlopen to parse URL as host & port HOT 1
- ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) HOT 1
- SSL: UNEXPECTED_EOF_WHILE_READING HOT 7
- imprecise types on `urllib3.Retry.new` / `urllib3.Retry.increment` HOT 1
- Investigate CI failures with Python 3.13.0a5 HOT 2
- "unable to get local issuer certificate", even though cURL works with the same website HOT 3
- Unclosed socket warning after HTTP 407 response from HTTP CONNECT proxy HOT 1
- All Retry backoff_factor to optionally start applying from first retry HOT 4
- Retry backoff_factor offset from second retry incorrectly computed HOT 2
- HTTPConnection.request chunked=False doesn't work properly HOT 8
- Need to exception for "SSLEOFError" on python 3.10, 3.11, 3.12 HOT 3
- After upgrading to 2.2.1: 'HTTPResponse' object has no attribute 'json' HOT 1
- Comment typo settimout settimeout HOT 1
- Dependency management issue HOT 2
- Fix test_redirecting_to_bad_url failure in Requests HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urllib3.